• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Help me with servlet - mapping  RSS feed

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a simple web application. I have one JSP and one servlet.

The code in JSP is
<html><head><title>Login Page</title></head>
<body>
<font size='5' color='blue'>Please Login</font><hr>

<form action='/valid.do' method='post'>
<table>
<tr><td>Name:</td>
<td><input type='text' name='employeeId'></td></tr>
<tr><td>Password:</td>
<td><input type='password' name='password' size='8'></td>
</tr>
</table>
<br>
<input type='submit' value='login'>
</form></body>
</html>

I have a ActionServlet class.
I want this index page be handled by this ActionServlet.

My web.xml has the following code:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>logic.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
But when I press submit button in index page, I am getting /valid.do is not availabel.
How to get rid of this problem?
Please help me.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ratna,

I strongly suggest you take out the / in your form action attribute and try again. If you look in you browser url, you'll find 2 slash before valid.do.

Good luck,

Troy.
[ October 14, 2005: Message edited by: Troy Peter ]
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, you have to start the form action with web context name. If your servlet is in context called web1.. then u have to have action for the form as /web1/valid.do
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ratna
i completely agree with Troy, remove the / from the form action. But i also have a doubt if one can set the url-pattern the way you have done.
 
Troy Peter
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Bhavna, setting the url-pattern that way is legal...it simply tells the container to watch for anything with extension .do.

Regards,
Troy.
[ October 15, 2005: Message edited by: Troy Peter ]
 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!