It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Help me with servlet - mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Help me with servlet - mapping" Watch "Help me with servlet - mapping" New topic

Help me with servlet - mapping

bhilla ratna
Ranch Hand

Joined: Jun 01, 2005
Posts: 59
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>
<font size='5' color='blue'>Please Login</font><hr>

<form action='/' method='post'>
<td><input type='text' name='employeeId'></td></tr>
<td><input type='password' name='password' size='8'></td>
<input type='submit' value='login'>

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

My web.xml has the following code:
But when I press submit button in index page, I am getting / is not availabel.
How to get rid of this problem?
Please help me.

Ratna bhilla<br />SCJP 1.4, SCBCD 1.3, SCWCD 1.4
Troy Peter

Joined: Oct 13, 2005
Posts: 14
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

Good luck,

[ October 14, 2005: Message edited by: Troy Peter ]
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
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/

Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
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.

SCJP1.4 (86%)
Troy Peter

Joined: Oct 13, 2005
Posts: 14
Hi all,

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

[ October 15, 2005: Message edited by: Troy Peter ]
I agree. Here's the link:
subject: Help me with servlet - mapping
It's not a secret anymore!