my dog learned polymorphism*
The moose likes Servlets and the fly likes How to package a project and install in tomcat webapps? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to package a project and install in tomcat webapps?" Watch "How to package a project and install in tomcat webapps?" New topic
Author

How to package a project and install in tomcat webapps?

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,
I built up an assignment with JSP and servlet. I am using JBuilder 6 and tomcat 4.
I put the assignment folder under webapps of tomcat and I added

to /conf/server.xml.
When I run http://localhost:8080/assignment/index.jsp, it can be displayed. However, the servlet classes cannot be found when I run the servlet functions.
I put all the servlet classes under /webapps/assignment/WEB-INF/classes/assignment/ folder.
I think that I set the path and docBase wrongly.
How should I set it?
Here is the java file:
package assignment;
public class StudentItem{
private int StudentID;
private String StudentName;
private double StudentGPA;
.....
}
All other jave files are under the package assignment.
All the compiled class files were put under JBuilder6/Tomcat4/webapps/assignment/WEB-INF/Classes/assignment/
e.g. StudentItem.class
Here is the jsp file:

All jsp files were put under
JBuilder6/Tomcat4/webapps/assignment/
The jsp page can display. However, jsp page cannot locate the class files.
http://localhost:8080/assignment/index.jsp - ok
If fill in the form and submit, it cannot locate the servlet:
http://localhost:8080/assignment/StudentItem
because it only dispatches to http://localhost:8080/StudentItem
The path with "assignment" is missed.
-----------------------------------------------
2nd question, I know how to use jar. , but how to use the war file? Where should be put it? Or, can I just put the assignment.war file without the whole assignment dir?
Can I put the war file under tomcat4/webapps in order to run that application?
What is the purpose of creating the war file?
just package the root directory?
Thanks for help
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
I found one thing that:
I have many jsp files under assignment folder. When I input localhost:8080/assignment/index.jsp, it is ok.
There are some link in index.jsp. If I click them, it will go to localhost:8080/add.jsp, but not localhost:8080/assignment/add.jsp.
It is the same with the servlet problem.
localhost:8080/servlet/StudentEntity, but not localhost:8080/assignment/servlet/StudentEntity
How should I configure in the web.xml about the servlet and jsp mapping? Is it related to this problem?
Also, if I put the war file under tomcat4/webapps in order to run that application, how can I do that? Do I just put assignment.war under tomcat4/webapps?
Thanks
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
hi andrew
Have you made proper entries of servlets in web.xml file ??
Please check that out, else you will need to write the class name & alias name of the servlet in the web.xml
hth
MB


Malhar Barai
SOA & Java Book
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Have you made proper entries of servlets in web.xml file ??
Sorry, what do you mean? Do you mean the web.xml under the assignment/WEB-INF?
I set it as follows and it returns an error when I started tomcat.


Could you tell me where could I find our the tutorial for web.xml?
Thanks
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Originally posted by Andrew Parker:
Have you made proper entries of servlets in web.xml file ??
Could you tell me where could I find our the tutorial for web.xml?
Thanks

http://edocs.bea.com/wls/docs70/webapp/webappdeployment.html#1012209
HTH
MB
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to package a project and install in tomcat webapps?
 
Similar Threads
Tomcat6 and Java Beans
Different ways for Contex
Path to servlet
My JSP dont work on Apache Tomcat
Servlet Context Virtual Sandbox