• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

issue with web.xml

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

please suggest to rectify the web.xml file.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Here you are mapping url-pattern to two different servlet name.
 
Babu Singh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you triggering the servlet?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

current directory is Webproject

E:\Webproject\WEB-INF\classes

 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic