I am trying to develop pages in JSP for e-mail.I have created login page and other pages.Now after the user authentication is finished and I need to send the user name to retrieve mails.I heard sessions can be used.I don't know anything about session creation and passing attributes of a session to next page. Please help me (it would be better if any example is provided).

Suppose that you are taking the username as input from the user in the Login page and passing it to the Login page's target page, then in the target page writing the belowwritten code would save the username in the session variable, which will be available to you throughout the session on all pages, unless otherwise mentioned in the @page directive.

<%
   String name = request.getParameter( "username" );
   session.setAttribute( "theName", name );
%>

PS : I think you should have rather posted this in the JSP forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.