user3908325 user3908325 - 1 year ago 77
Java Question

J2ee The requested resource is unavailable

Hello I know That this question has been asked before But unfortuanetly I didn t find among the answers proposed the one suitable for me
I m still new with J2ee lookin' forward for ur help
This is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login page</title>
<form action="" method="post"/>
<br> UserId: <input type="text" name="userId"/>
<br> password<input type="password" name="password"/>
<br><input type="submit"/>

package org.islem.login;

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 LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String userId,password;
userId= request.getParameter("userId");
password= request.getParameter("password");

LoginService loginService= new LoginService();
boolean result= loginService.authenticate(userId, password);
if (result)



package org.islem.login.service;

public class LoginService {
public boolean authenticate (String userId,String password)
if (password ==null || password.trim() =="") {
return false;
else return true;



Answer Source

Your form action is empty, you should fill it your servlet name in your case it should be like:

<form action="LoginServlet" method="post"/>

I assume you already define your servlet name at your web.xml

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download