Servlet Problem
Hi there
I am having a problem. Can anyone please help me.
I wrote a simple JSP with user name and Password --->
<%
String booknull = (String) request.getAttribute("wrongentry");
%>
<html>
<head>
<title>Login Screen</title>
<link rel="stylesheet" type="text/css" href=".\..\css\webapp.css">
</head>
<body>
<form name="login" method="get" action="./checklogin.servlet">
<table class="dosizing">
<% if((booknull != null) && (booknull.equals("false"))) { %>
<tr>
<td colspan="2" class="doalign">Invalid Store Name or Password</td>
</tr>
<% } %>
<tr>
<td colspan="2" class="doalign">Please enter your User Id and password below..</td>
</tr>
<tr class="dopad">
<td class="dodistance1">User Id:</td>
<td class="dodistance1"><input type ="text" id="userid" name="userid"
size="40" maxlength="40"/></td>
</tr>
<tr>
<td class="dopad">Password:</td>
<td class="dopad"><input type ="password" id="password" name="password"
size="40" maxlength="40"/></td>
</tr>
<tr>
<td></td>
<td class="dodistance"><input type="submit" value ="Log in">
</tr>
</table>
</form>
</body>
</html>
web.xml --->
<web-app>
<servlet>
<servlet-name>checklogin</servlet-name>
<servlet-class>com.titanamericas.servlets.CheckLogin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>checklogin</servlet-name>
<url-pattern>/checklogin.servlet</url-pattern>
</servlet-mapping>
</web-app>
Servlet --->
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.mysql.jdbc.Connection;
public class CheckLogin extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
System.out.println("Print 0");
ServletContext context = getServletContext();
HttpSession session = request.getSession();
System.out.println("Print 1");
String name = (String) request.getParameter("name");
String password = (String) request.getParameter("password");
System.out.println("Name Password " + name + " " + password);
//session.setAttribute("name", name);
//session.setAttribute("password", password);
System.out.println("Print 2");
// calling BookstoreBean.getStore()
BookstoreBean bb = new BookstoreBean();
System.out.println("Print 4");
//BookstoreBean ibook = bb.getStore(conn, name, password);
String ibook = null;
if (ibook == null) {
request.setAttribute("wrongentry", "false");
System.out.println("Print 5");
RequestDispatcher disp = request
.getRequestDispatcher("login.jsp");
if (disp != null)
disp.forward(request, response);
} else {
request.setAttribute("wrongentry", "true");
session.setAttribute("bookstore", ibook);
RequestDispatcher disp = request
.getRequestDispatcher("/books2.servlet");
if (disp != null)
disp.forward(request, response);
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);
}
I am trying to get this Servlet. I have printed like Print 0, Print 1 but in url I am getting ...localhost../app/jsp/checklogin.servlet?userid=1&password=1
But its showing HTTP Status 404 app/jsp/checklogin.servlet not found.
Anything that I am missing? Its not printing anything in the console that means its not going upto servlet. But JSP is good.. Because I am getting the page with value in the URL. So class path is set properly I think.
|