JSP, Servlet, and Java Classes location in Tomcat

M

Matt

In tomcat, I want to know JSP files, Servlets, and Java classes
should put in different locations:

I put all JSP files in the following:
C:\jakarta-tomcat-4.1.30\webapps\proj1

I put all servlet files in the following:
C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF\classes

I put all Java classes in the following with package proj1:
C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF\classes\proj1

When I execute servlet files, it has HTTP error 404, file not found.

I am not using web.xml at this moment. Please advise for the
workarounds so that it will work in all cases. thanks!!!
 
R

Ryan Stewart

Matt said:
In tomcat, I want to know JSP files, Servlets, and Java classes
should put in different locations:

I put all JSP files in the following:
C:\jakarta-tomcat-4.1.30\webapps\proj1

I put all servlet files in the following:
C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF\classes

I put all Java classes in the following with package proj1:
C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF\classes\proj1

When I execute servlet files, it has HTTP error 404, file not found.

I am not using web.xml at this moment. Please advise for the
workarounds so that it will work in all cases. thanks!!!
If you have no web.xml, you have no servlets. You must make the following
entries in web.xml for each servlet:
<servlet>
<servlet-name>someNameYouMakeUp</servlet-name>
<servlet-class>com.foo.ServletClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>someNameYouMakeUp</servlet-name>
<url-pattern>/foo</url-pattern>
</servlet-mapping>

The servlet-name is simply used to link servlet to mapping. The
servlet-class is the fully qualified name of the class file. The url-pattern
is the context-relative path that will cause this servlet to be invoked
(i.e. http://localhost:8080/myWebapp/foo in this example).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top