File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Yet another tomcat problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Yet another tomcat problem" Watch "Yet another tomcat problem" New topic
Author

Yet another tomcat problem

Latha Ganesan
Greenhorn

Joined: Feb 27, 2001
Posts: 12
Hi!,
I know there are lot of tomcat related threads in this forum,I solved all my problems till now by reading them. But this time I couldnot find an answer so I am posting a new thread...
I just want to test a simple servlet in tomcat and for that where do I put my .class files? All this while I was using servletrunner and I could directly run a servlet typing the servlet name is the url, can I do the same thing with tomcat or do we need to go through a html only(sorry if i am wrong). If html, where do I put them(which dir). Basically what is the significance of 'Path' and 'docbase' in the server.xml file?
Please help and thanx in advance.
Nizan
Greenhorn

Joined: Apr 18, 2001
Posts: 22
...and I searched and searched until I found the place to put my servlets. TomcatRoot\webapps\examples\WEB-INF\classes. There is a way to change this, but I haven't quite figured it out yet. Maybe one of the ranch hands could open the gate?


Nizan Horsefield<br />Weblogic Support<br />BMW
gayathri reddy
Greenhorn

Joined: Mar 29, 2001
Posts: 17
Hi Latha,
I am using tomcat I don't know about servletrunner.but i place my .classes in tomcat/jakartatomacat/webapps/examples/web-inf/classes folder.
and u can call in the url like this http://localhost:8080/examples/servlet/ur .class file name
hope this help u
-greddy
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
I know there are lot of tomcat related threads in this forum,I solved all my problems till now
by reading them. But this time I couldnot find an answer so I am posting a new thread...

I really appreciate you doing all the homework!

I just want to test a simple servlet in tomcat and for that where do I put my .class files?
As always there probably are many (confusing) ways of doing it...
One method I follow:

  • Create your project folder under webapps. So now you
    should be having a folder webapps/MyProject. This is known
    as your application root/context etc etc.
  • Under this context, create a folder WEB-INF and under
    which you have to create the folder classes. So you now
    have webapps/MyProject/WEB-INF/classes
  • Put your class files under the folder webapps/MyProject/WEB-INF/classes
  • Your HTML/JSPs go to the root of your application which is
    webapps/MyProject
  • The last thing you need todo is to add a new servlet context.
    Open the conf/server.xml file, copy one of the contexts say the
    examples and change the path and docBase

  • You should be able to access your servlet/JSP etc.

    All
    this while I was using servletrunner and I could directly run a servlet typing the servlet
    name is the url, can I do the same thing with tomcat or do we need to go through a html
    only(sorry if i am wrong). If html, where do I put them(which dir).

    I think you could directly call servlets. See above abt HTML files.
    Basically what is the
    significance of 'Path' and 'docbase' in the server.xml file?
    Please help and thanx in advance.

    Path as I understand is the part of URL which needs to be specified and docBase is the place where your application is
    deployed ie; your WEB-INF dir is under this dir and that this is
    your applications root.
    HTH.
    - satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
TomcatRoot\webapps\examples\WEB-INF\classes. There is a way to change this, but I
haven't quite figured it out yet. Maybe one of the ranch hands could open the gate?

Nizan:
You are right. There is no way to change this. It is printed in
stone in the Servlet Specs. Hence all application Servers
which implement the Servlet Specs. require this.
and I also should re-direct you to the javaranch names.jsp. Pl.
review this and re-register http://www.javaranch.com/name.jsp
Thanks for your cooperation.
- satya
vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
I think the only way you can change the structure is to add your application package name under \WEB-INF\classes folder.But that does not mean the change.Only we are separating the class files according to their applications and putting them in the corresponding pakages.So as suggested by Madhav I also always create my webapps folder(like myproject etc).The same name I give
to the package under "classes".
So "tomcatroot\webapps\myproject\WEB-INF\classes\myproject".


VAIBHAV <BR>SCJP
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

vaibhav:
just a clarification........IMO,
you are NOT changing the structure, you are just creating a
new context or a new application, which in its own way HAS to
follow the structure.
the way I see it....
- satya
Latha Ganesan
Greenhorn

Joined: Feb 27, 2001
Posts: 12
Hi all!,
Thanx a lot... yes it did work. Yes, u folks are right, we cannot change the structure, I suppose we can only create packages for our own applications and put it under 'classes' dir and classes in default package should go to the 'classes' dir straight.
Another ques, is tomcat an application server or it can serve only servlets and jsps (like what about ASP?)
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

Tomcat is an application server in its own way!
It serves applications based on JSP and Servlets.
Yes, it is limited to Servlets and JSP's.
Whats' that ASP you are talking abt
- satya
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
I think she means Microsoft's ASP (Active Server Pages) technology. If so, no Tomcat doesn't serve ASP pages.
regds
maha anna
 
wood burning stoves
 
subject: Yet another tomcat problem