I've done a simple system login. Consists of a form that asks to the user the id and password, after that this information sends to a servlet,
here is the code
// SERVLET
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private HttpSession moSesion = null;
private HttpServletRequest moRequest;
private HttpServletResponse moResponse;
private UsuarioBean moUser = new UserBean();
// Datos enviados por la URL
private String msLogin = "";
private String msPassword = "";
private String msCode = "";
/** Initializes the servlet.
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/** Destroys the servlet.
*/
public void destroy() {
}
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code>
methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
moRequest = request;
moResponse = response;
msLogin = request.getParameter("login");
msPassword = request.getParameter("password");
}
private void inicializeBean() {
moUser.setCode(msLogin);
moSesion = moRequest.getSession(true);
moSesion.setAttribute("objUser", moUser);
}
private void redirection(String sURL) throws ServletException, IOException
{
RequestDispatcher send = getServletContext().getRequestDispatcher(sURL);
send .forward(moRequest, moResponse);
}
}
The problem is when a user login, and then other user login, the first user sees the second user's details
Do you understand?
Would you help me?