This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Status 404

 
partha sama
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have just started learning servlets few days back. I am trying to execute a simple servlet program but there is an error coming up. I tried to check the previous posts related to this error but i could not solve it. I am posting the web.xml file, the html file and servlet to make things more clear to you.

html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action ="loginProcess">
Firstname : <input type = "text" name = "firstname"><br>
Lastname :<input type = "text" name ="Lastname"><br>
Password :<input type = "password" name ="passcode"><br>
<input type ="submit" value ="register">


</form>
</body>
</html>


web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Register</display-name>
<servlet>
<servlet-name>LoginServlet1</servlet-name>
<servlet-class>com.controller.LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet1</servlet-name>
<url-pattern>/loginProcess</url-pattern>
</servlet-mapping>
</web-app>


servlet:

package com.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {


@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("**logingserlvet**");
super.doGet(req, resp);
}

}

I checked whether the directory structure of the project and it seems to be correct. I think i have also given a write url pattern in web.xml file. I don't know if i am missing something. Any help is appreciated.
 
pankaj rawat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should check web.xml file.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the ServletsFaq where this issue is addressed.
 
pankaj rawat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In web.xml you have write the servlet name "LoginServlet1" which should be like that "LoginServlet".
 
Vineet P Rao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ideally a page with password should be sent as a POST method rather than a GET to avoid it from displaying it on the URL.

How are you deploying this application? Most probably the class file of the servlet is not where it should be.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vineet P Rao wrote:Ideally a page with password should be sent as a POST method rather than a GET to avoid it from displaying it on the URL.

However, sending it as a POST makes it no more secure than making it a GET. For security, the request must be encrypted via SSL.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic