facebook

Getting my bean property from a servlet

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #310930 Reply

    Karthik
    Member

    I have used a Java bean for setting and getting userName/id,password and its login process.
    Look at here :

    <h:inputText id=”userName” value=”#{UserBean.userName}”></h:inputText>

    The above code creates an instance of UserBean and sets the property userName to the entered value.

    Note:

    <h:commandButton value=”Login” action=”#{UserBean.login}” type=”submit”></h:commandButton>

    This calls the login() in UserBean which updates the database about login status directly using DAO’s.

    But Now i need to have a log out(which is a hyperlink) redirecting to a logout servlet.
    //com.servlet.logout.java
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession session = request.getSession();
    session.invalidate();
    response.sendRedirect(request.getContextPath()+”/loginForm.faces”);
    }

    How do i get now update the database using the DAO thats available for updation that I did using the bean(previously did for login)?.

    Two issues that i face now:
    1) If I use servlet to invalidate request, how do I then use logout method in DAO?
    2) As I have to call the DAO’s updateLog(String userName,String logStatus) from where could I get userName from?

Viewing 1 post (of 1 total)
Reply To: Getting my bean property from a servlet

You must be logged in to post in the forum log in