Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cant call servlet from a jsp

 
Jason Crest
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,
im really new at jsp/servlets
i have a form that is trying to call a servlet
it looks something like this

processform.java is a servlet tahts in the same directory as the jsp thats calling it. processform.java has also been compiled into processform.class
when i go to excecute the form i get the following error
HTTP Status 404 - /axis/processform
--------------------------------------------------------------------------------
type Status report
message /axis/processform
description The requested resource (/axis/processform) is not available.

--------------------------------------------------------------------------------
Apache Tomcat/5.0.16
note: axis is installed
thanks a bunch
 
john von
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally, servlets and JSP should not be in the same folder. Better check the documentation of your web server to locate which folder should your servlets and other classes be.
[ May 11, 2004: Message edited by: john von ]
 
Ankur Srivastava
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your web application should have a public directory which will be the home for your application. This public directory should contain the jsps, htmls, xml and a WEB_INF folder which again contains a classes folder where we store the compiled servlet or other utility classes. The WEB_INF folder also contains web.xml file which has servlet mappings and a lib directory which contains the other jar files needed by the application.
This is the general structure of a web application can change from container to container.
 
Jason Crest
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried adding the processform.class to this direcory
/jakarta-tomcat-5.0.16/webapps/axis/WEB-INF/classes
and this directory
/jakarta-tomcat-5.0.16/webapps/axis/WEB-INF/
still no luck in either case
 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your servlet ProcessForm.java is under axis package? Try creating axis directory under ../classes and putting ProcessForm.class under axis directory.
 
Jason Crest
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no luck ,
this is really starting to worry me
 
Francis Amanfo
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jason Crest:
no luck ,
this is really starting to worry me

Hi Jason,
Have you declared and mapped your servlet class in the web.xml?
I suspect that's where the problem lies.
Francis
 
Jason Crest
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh gosh, no i havnt. how do i do that?
 
Jason Crest
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried adding
<servlet-mapping>
<servlet-name>processform</servlet-name>
<url-pattern>/processform</url-pattern>
</servlet-mapping>
i then shut down and restarted tomcat
it didnt display any of my jsp's like it normally would, adding that bit above caused some problems it looks like
 
Ankur Srivastava
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mapped your servlet name to the servlet class in your web.xml
If not do it like this
<servlet>
<servlet-name>processform</servlet-name>
<servlet-class>example.processform</servlet-class>
</servlet>
Replace example by the package name in your case. And have the same directory structure in your classes folder in WEB_INF as the package declaration.
And as in servlet mapping you have given the url-pattern as <url-pattern>/processform</url-pattern>, the forms action should be /processform not processform
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!