Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have developed a jsp page for login form along with a servlet named main.
code of Home.jsp:
<%--
Document : Home
Created on : Oct 11, 2014, 2:55:09 PM
Author : Devil -Boss
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<form method="post" action="Main">

Username: <input type="text" name="txtusername">

password: <input type="password" name="pas">

Go : <input type="submit" value="submit">



</form>

Hello World!


</body>
</html>
----------------------------------------------------------------------------------------
the code of main.java:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Main;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Session;

/**
*
* @author Devil -Boss
*/
public class Main extends HttpServlet {

/**
* Processes requests for both HTTP
* GET and
* POST methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
System.out.println("k");
PrintWriter out = response.getWriter();
try {
String username = request.getParameter("txtusername");
String password = request.getParameter("pas");
if((username.equals("Tushar")) && password.equals("nitin123"))
{
response.sendRedirect("Home.jsp");
// out.println("Most Welcome"+username);
}
else
{
response.sendRedirect("Sorry!.jsp");
}
} finally {
out.close();
}
}
}
but when i run the whole project it produce the following exceptions:

HTTP Status 404 - /Hospital_Management/

--------------------------------------------------------------------------------

type Status report

message /Hospital_Management/

description The requested resource (/Hospital_Management/) is not available.

--------------------------------------------------------------------------------

Apache Tomcat/7.0.22
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900