1

I'm working on a simple login app using mvc (JSP pages + servlets, running on Apache Tomcat server in Eclipse + Mysql database).

When I access my servlet from the direct URL:

http://localhost:8181/stage/LoginControlerdo

The servlet's instructions get executed, but do not when the servlet is invoked from the JSP form, it shows a blank page instead.

(Servlet's instructions are just simple messages that show up when the servlet is accessed directly of after actualising the page but not when called from the JSP form).

As you can see I'm using port 8181; I don't think the problem has anything to do with the web.xml config since the server starts correctly but here is a copy

Web.xml :

<servlet>
  <servlet-name>LoginContro</servlet-name>
  <servlet-class>attakmili.com.LoginControler</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>LoginContro</servlet-name>
  <url-pattern>/LoginControlerdo</url-pattern>
</servlet-mapping>

If anyone has an idea about what's going on I would be grateful.

The JSP code:

<form action="LoginControlerdo"  method="post">
<table>
<tr>
<td>Pseudo</td>
<td><input type="text"  name="pseudo" /></td>
</tr>
<tr>
<td>Mot De Passe</td>
<td><input type="text"  name="password" /></td>
</tr>
<tr>
<td colspan="2" ><input type="submit" value="LOGIN" /></td>
</tr>
</table>
<br>
</form>
greg-449
  • 109,219
  • 232
  • 102
  • 145
nabsterz
  • 25
  • 4

2 Answers2

1

You are using POST method to submit your form, but when you access the servlet from browser directly GET method will be used.

You have to use the HttpServlet.doPost(HttpServletRequest, HttpServletResponse) to implement you logic.

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
  • That was it, that solved it thank you very much. (Copied the instructions from doGet() to doPost ()) – nabsterz Aug 22 '14 at 15:14
0

This should work , (Add a slash before LoginControlerdo)

<form action="/LoginControlerdo"  method="post">
<table>
<tr>
<td>Pseudo</td>
<td><input type="text"  name="pseudo" /></td>
</tr>
<tr>
<td>Mot De Passe</td>
<td><input type="text"  name="password" /></td>
</tr>
<tr>
<td colspan="2" ><input type="submit" value="LOGIN" /></td>
</tr>
</table>
<br>
</form>
Pawan
  • 31,545
  • 102
  • 256
  • 434