Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
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 April 19th, 2007, 12:53 AM
Authorized User
 
Join Date: Aug 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default sharing variables throughtout the jsp application

i've declared and defined some variables(including arrays] and some vectors on my jsp page... now, i want their values on my every JSP page, i mean i want to share these variables and vectors throughout my jsp application, how to do this ???

 
Old April 20th, 2007, 12:37 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
The best way of using information needed by the jsp files is to declare java object which will contain all kind of the information. for example user information[first name ,last name , his role, etc.] one java object and books information [book title, price, etc.. if its a online library application], so we'll have to java objects one for user information and other for books and similarly for other kind of info.

For your problem declare a java object which holds the vectors arrays what ever you need and create and initialize this object in the jsp you've mentioned and finally add this object to session, so that you can access it where ever you want.

Hope its clear to you.

Regards,
Rakesh
 
Old April 22nd, 2007, 10:18 PM
Authorized User
 
Join Date: Aug 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey thankx dude...
but plz tell me 1 thing, which method may i use 2 add object in the session, setAttribute(String,Object) or putValue(String,Object)

 
Old April 23rd, 2007, 11:36 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
You've to use setAttribute(). putValue() is deprecated.

Regards,
Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using global variables in jsp sumon_24_feb JSP Basics 1 March 23rd, 2007 07:45 AM
Application variables brettk_1 VB.NET 1 February 9th, 2007 08:37 AM
MDI Application and Sharing Objects ~Bean~ General .NET 4 November 18th, 2005 05:24 PM
Unassigned Application Variables wboctor BOOK: Beginning ASP 3.0 6 November 3rd, 2003 02:35 PM
JSP 2.0 book question...re: variables troutguy All Other Wrox Books 1 August 5th, 2003 05:41 PM





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