aspose file tools*
The moose likes JSP and the fly likes Servlet Context Virtual Sandbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Servlet Context Virtual Sandbox" Watch "Servlet Context Virtual Sandbox" New topic
Author

Servlet Context Virtual Sandbox

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,
I built a web application which has the following structure:
Assignment\
index.jsp
add.jsp
images\
logo.gif
Student\
record.jsp
WEB-INF\
web.xml
classes\
assignment\StudentServlet.class
lib\
dbLibrary.jar
I packaged it as Assignment.war and it was put under C:/tomcat4/webapps/,
i.e. C:/tomcat4/webapps/Assignment.war
I did not set the server.xml for the Context path as it is only a war file.
When I type:
http://localhost:8080/Assignment/index.jsp, it will display properly.
There are 3 links to
1. add.jsp and
2. /Student/record.jsp and
3. assignment.StudentServlet
in the index.jsp page.
When I click the links to add and record jsp pages and the StudentServlet, it said no such files.
I saw the URL are
1. http://localhost:8080/add.jsp
2. http://localhost:8080/Student/record.jsp
3. http://localhost:8080/servlet/StudentServlet
instead of
1. http://localhost:8080/Assignment/add.jsp
2. http://localhost:8080/Assignment/Student/record.jsp
3. http://localhost:8080/Assignment/servlet/StudentServlet
Here is the web.xml:
<servlet>
<servlet-name>StudentServlet</servlet-name>
<servlet-class>assignment.StudentServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>StudentServlet</servlet-name>
<url-pattern>/StudentServlet</url-pattern>
</servlet-mapping>
I think the web.xml has problem. It has not mapped to correct context "Assignment".
How should I set it in web.xml?
I use tomcat 4 and JBuilder 6.
Thanks
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
Hi Andrew,
why don't you always link from root?
/Assignment/add.jsp
/Assignment/Student/record.jsp
etc.
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,
Sorry, I am a newbie and I do the project under JBuilder.
In the JBuilder, here is the structure:
package assignment;
public class StudentServlet {}
Root directory
index.jsp
add.jsp
/Student/record.jsp
The 3 resources in my index.jsp are:
1. /add.jsp
2. /Student/record.jsp
3. /servlet/StudentServlet
The Jbuilder packaged them as an Assignment.war file.
When I typed http://localhost:8080/Assignment, it displayed http://localhost:8080/Assignment/index.jsp.
Why not http://localhost:8080/index.jsp?
If it is http://localhost:8080/Assignment/index.jsp, why not the context "Assignment" cannot be located as follows?
1. http://localhost:8080/Assignment/add.jsp
2. http://localhost:8080/Assignment/Student/record.jsp
3. http://localhost:8080/Assignment/servlet/StudentServlet
If I use another war file name such as assign.war, but the resources links are
1. /Assignment/add.jsp
2. /Assignment/Student/record.jsp
3. /Assignment/servlet/StudentServlet
When I typed http://localhost:8080/assign, it cannot find http://localhost:8080/Assignment/index.jsp.
So, how can I solve it?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

If you put your code and directory structure maps between UBB CODE tags, the formatting will be preserved. Without them, your directory structure maps are useless, and code is hard to read.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Context Virtual Sandbox