setAttribute « Session « JSP-Servlet Q&A





1. Where do I put session information? In HttpServletRequest.setAttribute()?    stackoverflow.com

I have a servlet class which handles login. At the end of my login procedure, I do this:

// jsp page
...
Helper.loginUser(request);

// Helper.java
public static void loginUser(HttpServletRequest request) {

    request.getSession().setAttribute("username", "john");
}
in ...

2. Servlets: setAttribute in HttpServletRequest vs setAttribute in HttpSession    stackoverflow.com

whats the difference between setAttribute() in HttpServletRequest and setAttribute() in HttpSession? Under what circumstances are they used? Thanks for any help!

3. why not session.setAttribute working ?    coderanch.com

I want to display count of page hit through session but every time its displaying s1=0,either its not setting the attribute of session or what? The code is given below : <%@ page import = "java.io.*, java.util.*, java.sql.*" session="true" %> <%! int a; %> <% Integer s1 = (Integer)session.getAttribute("sess"); out.println("s1 before " + s1); if (s1==null) { s1 = new Integer(0); ...

4. session.setAttribute() not working    coderanch.com

file name GetName.html

what is your name?

file name SaveName.jsp <% String name = request.getParameter( "username" ); session.setAttribute( "theName", name ); %> Continue file name NextPage.jsp Hello, <%=session.getAttribute("theName") %> when ...

6. session setAttribute null not working    coderanch.com