Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

configuring servlets on tomcat4  RSS feed

 
prasad hagargi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Can anybody guide me in configuring servlets in a new context other than the examples context ,
on tomcat4.
when i try to invoke a servlet, file not found
exception is occurring.
the structure of the web.xml is like this
<servlet>
<servlet-name>
UpdateLicense
</servlet-name>
<servlet-class>
UpdateLicense
</servlet-class>
</servlet>

--prasad
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you configured the url pattern for servlets
in web.xml??
 
prasad hagargi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i have mapped it
as
<servlet-mapping>
<servlet-name>
UpdateLicense
</servlet-name>
<url-pattern>
/ UpdateLicense </url-pattern>
</servlet-mapping>
even then iam not able to invoke it
it still gives me the file not found exception
 
prasad hagargi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should i be editing the web.xml or the server.xml
of the D:\jakarta-tomcat-4.0.6\conf in this case.
if yes then what should i edit ?
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,
suppose you want to call ur servlets like:
http://servername/myapp/servlet/mypackage.myservlet
then you should uncomment the servlet maaping for "invoker" servlet in web.xml in tomcat/conf directory
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't bother uncommenting that servlet/* mapping. It's not a 'best practice' way of invoking servlets!

the servlet mappings for each application should be in that application's web.xml. p.s. - if you tried to put a servlet mapping in server.xml, it would throw a parsing exception. They're not allowed in this file.

Is there a space between your '/' and UpdateLicense? (there shouldn't be).

Also... moving this from Servlets -> Apache/Tomcat
 
prasad hagargi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below is the structure of the web.xml of the application,iam trying to deploy

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>test.HelloWorldExample</servlet-class>
</servlet>
</web-app>
while invoking iam using the url
http://localhost:8080/test/servlet/HelloWorldExample
the context tag in server.xml is
<Context path="/test" docBase="test" debug="0"
reloadable="true" crossContext="true"/>
i still am getting
The requested resource (/test/servlet/HelloWorldExample) is not available.
 
prasad hagargi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using tomcat4.0.6 on win nt,
heys guys help me out.
 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in your logs. Looking at your web.xml I see that some elements namely description and name are missing. I'm not sure of their order(It matters!!). I'm guessing the xml parser has thrown a parser exception during validation. If thats the case, try adding those elements in as they are mandatory and they should be in the correct order.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!