Wrox Programmer Forums
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2007, 11:19 PM
Registered User
 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to winsonkkp
Default Session problem

Does anyone know how to set session and get session value in JSP?

Hello
 
Old July 21st, 2007, 12:09 AM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you are referring to obtaining sesson onject, session is one of the variables available in the jsp page by default and this refers to the session object. If you have to put some attributes use

<%session.putAttribute(String,Object);%>

Let me know if you are referring to something else.

-eNJay
 
Old July 21st, 2007, 05:30 AM
Authorized User
 
Join Date: Jul 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

putAttribute method is not present in session object.

Instead you have to use setAttribute to store a value in session.

The usage is: <%session.setAttribute(String, Object);%>

You can get the value with getAttribute method and the usage is below

<%=session.getAttribute(String)%>
 
Old August 23rd, 2007, 05:00 AM
Registered User
 
Join Date: May 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

when you set values to or get values from server, you have to use sessions.

To set values in server

session.setAttribute(sessionObject, StringVariable);

To get values from server

String strVariable=(String)session.getAttribute(sessionOb ject);

for example

if u stored Username in "users" variable,u have to set like this

<% String users="xxxxxx";%>
<% session.setAttribute("USER", users);%>

to get:

<%String strGet=(String)session.getAttribute("USER");%>


i hope, it will help u.

bye


 
Old August 29th, 2007, 02:29 AM
Authorized User
 
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<% session.setAttribute("vaiable",value ); %>
<% String str=(String) session.getAttribute("variable"); ; %>

http://studyjava.org/forums/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Out Problem kasipandian J2EE 3 March 21st, 2008 03:35 PM
session problem MunishBhatia ASP.NET 2.0 Professional 9 October 6th, 2007 04:06 AM
Session problem abdulweb General .NET 3 August 27th, 2007 08:01 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.