File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

issue with web.xml

 
Babu Singh
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have some servlet classes and jsp files.

i made a Servlet class ServletHome.java which work only transfer the control to Vij.jsp. Vij.jsp in turn call a another jsp file Indus.jsp. this jsp transfer the control to another servlet class ServletOne.java which perform
some business logic on some java classes then dispaly the result on same jsp file Indus.jsp from where i called ServletOne.java

i am configuring web.xml.but due to some mistake in web.xml, i am founding exception.

web.xml

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
particularly your servlet-mapping is wrong .
http://jakarta.apache.org/cactus/integration/howto_tomcat.html
 
Babu Singh
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

please suggest to rectify the web.xml file.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


<servlet-mapping>
<servlet-name>ServletHome</servlet-name>
<servlet-name>ServletOne</servlet-name> //remove
<url-pattern>/Vij.jsp</url-pattern>
</servlet-mapping>



remove one of the servlet-name. please show some effort . it will help you to solve problem / get knowledge
 
sujith Acharya
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here you are mapping url-pattern to two different servlet name.
 
Babu Singh
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i did some change in web.xml


now it deployed. but when i click on the link of ServletHome , it give error Error 404 not found.


ServletHome.java is:


please help.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you triggering the servlet?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I really should have a handy cut and paste to say this since it is a common beginner error for people moving from desktop applications to a container hosted environment.

ALL classes in servlets should be in named packages and the class files stored accordingly.
What you have there is a class in the "default" package - a JVM will look for it in the "current" directory. You have no control over the current directory therefore the class is never loaded.

Bill
 
Babu Singh
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

current directory is Webproject

E:\Webproject\WEB-INF\classes

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you missed the point: place the Servlets in a non-default package or they won't work.
 
Babu Singh
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i placed all servlet classes in a servlet folder under E:\Webproject\WEB-INF\classes

i also placed vij folder under servlet class. vij folder have some java classes. one servlet use this java classes. if i did not place the vij folder under servlet folder one servlet are not compile.

so root for servlets classes is:
E:\Webproject\WEB-INF\classes\servlet

root for java classes is:
E:\Webproject\WEB-INF\classes\servlet\vij

web.xml is:

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it must be



I do suggest you to *google* about web application structure and make a *Hello World* Servlet
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
current directory is Webproject

E:\Webproject\WEB-INF\classes


No, you have little to no control over what a servlet container thinks is the "current" directory.

You should become familiar with the official servlet API and the directory structure requirements. Why not start at this Sun/Oracle site instead of flailing around.

Bill
 
Mark E Hansen
Ranch Hand
Posts: 650
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote: it must be


Yes, except that I think an incorrect value has been used for the servlet class, so I don't think servlet is actually the package name for the class file - instead, I think the poster placed the url pattern into this field by mistake. I think the poster still doesn't understand the need for packages, or doesn't understand what they are.
Seetharaman Venkatasamy wrote:I do suggest you to *google* about web application structure and make a *Hello World* Servlet

That's good advice. There's good 'getting started' help in the ServletsFaq on the Ranch.


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic