Results 1 to 3 of 3
  1. #1
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default problems with Login

    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

    Java 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?

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default

    Hi,
    The servlet doesn't instance once time, it isn't correct
    Please visit this link, maybe it helps you
    http://www.acknowledge.co.uk/java/tu...threading.html

    Another thing that I noticed is: Sessions!!!!
    each new browser that calls your application creates a session, it isn't the same for every browsers.
    good luck

  3. #3
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    Maybe you should invalidate (session.invalidate) the old session before create a new one, that is to say log out

Similar Threads

  1. Login Forms
    By dankonsoer in forum New To Java
    Replies: 1
    Last Post: 08-07-2008, 12:06 PM
  2. Login with mysql
    By fernando in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 03:30 PM
  3. I want to get values from login jsp
    By trill in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:33 AM
  4. Struts and login
    By Peter in forum Web Frameworks
    Replies: 2
    Last Post: 07-04-2007, 03:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •