#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0

    Question JSP Rookie here.... I need help with what goes where


    Hello all,

    I am new (and I mean very new) to JSP and Apache /Tomcat. I have installed on my system
    the following:

    j2sdk1.4.1_02

    Apache/httpd 2.0.45

    Tomcat 4.1.24-LE

    mod_jk 2.0.43.so (Apache/Tomcat connector)


    All installed no problem. I have gone on the web to find some JSP tutorials and found 2. But they are a bit dated and refer to WEB-INF , jsp webapps folders that are in different locations from what was installed in the above releases.... (Tomcat) .

    Each of these tutorials point to different WEB-INF folders as an example and it's confusing the hell out of me.

    Based upon my versions listed above... can anyone help me out ????? All I would like is to know where the heck to put my files so I can run my stuff.


    Thanks

    Mike
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Hmm, the WEB-INF directory is located in your web apps directory root. Every web app has its own WEB-INF. So, if you make a web app called "myApp", then the directory structure would be something like

    myApp
    myApp/WEB-INF
    myApp/WEB-INF/classes
    myApp/WEB-INF/lib

    web accessible files go in the myApp dir (and any new directories you make under myApp). Servlets and beans go in the WEB-ING/classes dir. Jar files go in the lib dir.

    Is there a dir in the tomcat install called "webapps"? That is where your web app will go. All new web apps can be dropped into this dir as long as they contain a WEB-INF dir with a web.xml file of their own. So in the above example we would have

    path_to_tomcat/webapps/myApp/...

    Hope that helps.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0
    so if I understand it. correctly:

    Here is my Tomcat path:


    /usr/local/tomcat/webapps/ROOT/WEB-INF


    Is MyApp under ROOT or WEB-INF????

    e.g.= /usr/local/tomcat/webapps/ROOT/WEB-INF/MyApp/

    and then the subdirectories under MyApp ???

    or is it

    /usr/local/tomcat/webapps/ROOT/MyApp

    subdirectories....???
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    No. ROOT should be the default webapp. You can add classes directly to the ROOT/WEB-INF/classes dir if you want.

    However, if you make a NEW web app, then it goes in the webapps dir parallel to ROOT. You would also have to change the server.xml to specify another web app. This is the common way of adding new applications to an app server.

    Adding a new web app:
    /usr/local/tomcat/webapps/myApp
    /usr/local/tomcat/webapps/myApp/WEB-INF
    /usr/local/tomcat/webapps/myApp/WEB-INF/classes
    /usr/local/tomcat/webapps/myApp/WEB-INF/lib

    In your WEB-INF you need a web.xml file that is respoinsible for telling the app server what servlets and such are loaded for this particular web app. Take a look at the web.xml that is in the ROOT/WEB-INF if there is one.

    You access the ROOT web app by using the host name only. Requests to http://hostname/* will be serviced by the default app, ROOT int his case. If you added a new web app called myApp and set it up in your server.xml, then you would access it by the following url

    http://hostname/myApp/*

    When the app server got a request with myApp in the url, it would route it to that dir automatically. This make sense?

    Remember that the url that is requested will not always map directly to the file system as it is laid out.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0
    Okay I think I'm understanding now..... lemme try out my stuff an get back to ya.... the ROOT directory was confusing me because it had a
    WEB-INF subdirectory... I understand the default(ROOT) logic you were mentioning..

    Thanks for the insight... I'm sorry if I sound a bit dense on it, but this is my first JSP experience

    I'll let ya know how it goes...


    Thanks again

    Mike
    Cleveland Ohio
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0
    Remi - I'm still having problems..... it still wont find my .jsp file... if you wouldn't mind please
    look at this link:

    http://www.sitepoint.com/print/1027

    scroll down to the "A Simple JSP" sub heading about 3/4 way down.... I have followed these instructions and your directory guide. Now it calls to create a sub directory called "jsp"..... I'm gettin a bit more confused by this one.... sheesh
    which I did but it still croaks with not being able to find the count.jsp file.... egads

    Thanks very much

    Mike
  12. #7
  13. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    OK, the directions it is giving are misleading. According to the url's it is specifying, you should NOT make a 'jsp' dir. Put count.jsp in the sitepoint dir. The person who wrote that guide was confused, possibly about the preceding paragraph concerning the "examples" app they were talking about, which has a "jsp" dir. WEB-INF should be a subdir of sitepoint

    path-to-tomcat/webapps/sitepoint
    path-to-tomcat/webapps/sitepoint/count.jsp
    path-to-tomcat/webapps/sitepoint/theEnd.html
    path-to-tomcat/webapps/sitepoint/WEB-INF
    path-to-tomcat/webapps/sitepoint/WEB-INF/web.xml
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0
    Fantastic!!!!.. that worked... I see now where the wording was a bit misleading... I took his instruction to create another subdirectory called jsp where he was referring to the Sitepoint directory.... Thank you SO much!!!!

    I have one more quick question: what do you use to create your JSP's???? I was toying with Eclipse, and then someone told me to use ANT (which I have never used)..... I guess I'm looking for something that has good Project Management , which will dump the right file (.jsp,.html, .xml ) files in the appropriate folder without alot of manual copying etc etc.....


    Mike
  16. #9
  17. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Hmm, I use Websphere Studio Application Developer, which is based off of Eclipse. IBM made a jsp/servlet/J2EE portion for it which works greate. Eclipse does not have jsp support by default and there were no good jsp plugins for it when I was using it(6-8 months ago), but there may be now. Unfortunately, WSAD is sold by IBM and costs over a $1000 I believe.

    I know that Suns Netbeans IDE has jsp/servlet support built in. It is free. You may want to try that.

    Ant is a deployment/build tool. It is not an IDE for development. It is equivalent to 'make' in linux.
    Last edited by Nemi; June 3rd, 2003 at 02:11 PM.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0
    Thanks for the info and the help. I really appreciate it...
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    3
    Rep Power
    0
    Nemi,

    I gained insight into the J2EE directory structure through your replies. greatly appreciated.

    You said "if you make a NEW web app, then it goes in the webapps dir parallel to ROOT"

    Can we create a New Web app, which is not under webapps directory?

    I read somewhere that we can set the following in the server.xml.
    <Context path = "" docBase = "c:\myapp\" reloadable = "true"/> to actually achieve that.

    I have tried it, and it does not work. Do you have any information on this?

    Thanks!
  22. #12
  23. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    I have not done this, sorry. I am familiar with the spec, but I use Websphere 3.5 in deployment and Websphere 5 for development.

    This doc may help you. It says what you are trying should be possible. The only thing I can see that is different is that you are using backslashes in the path name instead of forward slashes as he has in his example.

    http://kevinj.develop.com/javahome/javatomcat.jsp

IMN logo majestic logo threadwatch logo seochat tools logo