Results 1 to 6 of 6

Thread: Session Handling In JSP

  1. #1
    Join Date
    Nov 2009
    Posts
    877

    Session Handling In JSP

    Hello, I am having knowledge of Core Java and learning JSP by own. If you are having any type of information about the Session handling in JSP then please provide me that, so that I can able to understand it as soon as possible. I have checked on internet, but explanation is quiet complicated. So, if anyone is having details on it, then give me in simple steps.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Session Handling In JSP

    Session management can be achieved by using the following things:
    • Cookies
    • URL rewriting
    • Hidden form fields

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Session Handling In JSP

    Most of the time if you consider then you will come to know that the session is work with the user base application. If user login and login gets successful then the session object is used to set the session. It is set for the maximum time of the session. It is provided by the web server or it is defined by the application. The session object gets destroyed when the session is closed by the user or it expires.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Session Handling In JSP

    You can simply make use of the code of the Session Handling in JSP from below:
    Code:
    <html>
    	<head>
    		<title>Session Jsp</title>
    	</head>
    	<body>
    	<form method = "post" action = "session.jsp">
      <font size = 6>Name<input type = "text" name = "str"></font><br><br>
      <font size = 6>Password<input type="password" name = "pwd" >
                    </font><br><br>
    		<input type = "submit" name = "submit" value = "submit" >
    	</form>
    	</body>
    </html>
    <%  
        String str = request.getParameter("str");
    	String pwd = request.getParameter("pwd");
    	if(str.equals("Williams") && pwd.equals("abcde"))
    	{
    		session.setAttribute("userstr",str);
    		response.sendRedirect("NextPageAfterFirst.jsp");
    	}
    	else
    	{
    		response.sendRedirect("SessionManagement.html");
    	}
    	%>
    <html>
    	<head>
    		<title>Welcome in In the program of URL rewriting</title>
    	</head>
    	<body>
    <font size = 6>Hello</font> <%= session.getAttribute("userstr") %>
    	</body>
    </html>

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Session Handling In JSP

    You can able to Remove JSP Session Variables with the help of below step:
    When the session in not needed then you can simply remove that forcefully. For that you need to make use of the method below:
    Code:
    session.invalidate();
    You can simply check for the new session by the help of following method:
    Code:
    session.isNew();

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Session Handling In JSP

    Use the code below for session in jsp:
    Code:
    <%@ page language="java" import="java.util.*"%>
    <%
    String str=request.getParameter("sessionVariable");
    session.setAttribute("MySession",str);
    %>
    <html>
    <head>
    <title>Cookie IN JSP</title>
    </head>
    <body>
    Session :    <%=(String)session.getAttribute("MySession")%>
    </body>
    </html>

Similar Threads

  1. Replies: 4
    Last Post: 17-01-2011, 11:14 AM
  2. Replies: 4
    Last Post: 24-12-2010, 07:58 AM
  3. Exception handling in PL/SQL
    By Ameeryan in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 11:04 PM
  4. Replies: 3
    Last Post: 31-07-2009, 01:09 PM
  5. Handling NULL in ASP.NET
    By Techie in forum Software Development
    Replies: 3
    Last Post: 21-09-2005, 06:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,618,717.34122 seconds with 17 queries