Thursday, 15 January 2015

java - J2ee The requested resource is unavailable -


Hello I know this question has been asked before but unfortuanetly I did not think the answer seems to be in the middle Propose a suitable for me! // W3C // DTD HTML 4.01 transitional // - DOCTYPE html public ", Meter still looking forward to J2ee ur help" with this new code. Login.jsp


  & Ltn "" http://www.w3.org/TR/html4/loose.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; & Lt; Title & gt; Login page & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form action = "" method = "post" / & gt; & Lt; Br> UserId: & lt; Input type = "text" name = "user id" /> & Lt; Br> Password & lt; Input type = "password" name = "password" /> & Lt; Br> & Lt; Input type = "submit" / & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Log InServlet. Java

  package org.islem.login; Import java.io.IOException; Import javax.servlet.ServletException; Import javax.servlet.annotation.WebServlet; Import javax.servlet.http.httpServlet; Import javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Import org.islem.login.service.LoginService; Public Class Login Incentive HTCServlet {Private Static Final Long Serial Weirsian UID = 1 L; / ** * SEE HttpServlet # doPost (HttpServletRequest request, HttpServletResponse response) * / Protected Zero doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO auto-created method stub string userId, password, UserId = request .getParameter ("userId"); Println (userId); Password = request.getParameter ("password"); LoginService loginService = New LoginService (); Boolean results = Login service. Authentication (user ID, password); If (result) {response.sendRedirect ("home.jsp"); Return; } And {response.sendRedirect ("login.jsp"); Return; }}  

}

LoginService.java

  package org.islem.login.service; Public class LoginService {Public Boolean Certified (string userId, string password) {if (password == null} password.trim (== "") {return false; } And true back; }}  

After the name

Your form action is empty, you must fill it in your Should be like the case:

  & lt; Form action = "loginServlet" method = "post" />  

I think that you already define your servlet name on your web.xml


No comments:

Post a Comment