Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 18th, 2007, 11:19 PM
Registered User
 
Join Date: Jun 2007
Location: Sepang, Selangor, Malaysia.
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
Reply With Quote
  #2 (permalink)  
Old July 21st, 2007, 12:09 AM
Authorized User
 
Join Date: Apr 2005
Location: , , India.
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
Reply With Quote
  #3 (permalink)  
Old July 21st, 2007, 05:30 AM
Authorized User
 
Join Date: Jul 2007
Location: , , India.
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)%>
Reply With Quote
  #4 (permalink)  
Old August 23rd, 2007, 05:00 AM
Registered User
 
Join Date: May 2007
Location: , , .
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


Reply With Quote
  #5 (permalink)  
Old August 29th, 2007, 02:29 AM
Authorized User
 
Join Date: May 2007
Location: , , .
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/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.