473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

JSP: storing Object to pageContext: old fashioned?

JSPs seem to offer more than one way of storing Objects to a session
context for session tracking purposes.

Both these seem to work Ok in my JSP code on Tomcat 5.0.x:

// using pageContext with session scope
pageContext.setAttribute("name", myObject, PageContext.SESSION_SCOPE);

// using the session context of HttpServlet
session.setAttribute("name",myObject);

Whats the difference here? Is there a preferred way to do this?

Thanks
Bruce

Dec 14 '06 #1
1 2267
br**********@my-deja.com wrote:
JSPs seem to offer more than one way of storing Objects to a session
context for session tracking purposes.

Both these seem to work Ok in my JSP code on Tomcat 5.0.x:

// using pageContext with session scope
pageContext.setAttribute("name", myObject, PageContext.SESSION_SCOPE);

// using the session context of HttpServlet
session.setAttribute("name",myObject);

Whats the difference here? Is there a preferred way to do this?

Thanks
Bruce
Hi Bruce,

Wrong newsgroup. :-)
Your question is about J2EE, not JavaScript, so try comp.lang.java or
comp.lang.java.help instead.

To your question, my Javaskills are rotting a bit, but I think they are
identical, but setting the attribute directly on session makes a lot more
sense to me than doing it via PageContext.SESSIONSCOPE.

Regards,
Erwin Moller
Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Thomas P. Fuller | last post by:
Hi, thanks in advance for any help you can offer me. I'm wrestling with the following problem: The following is on the same jsp page and say that the product parameter is "foo": // This...
1
by: Alex | last post by:
Hi all- I am having a little trouble storing resultset data from a javabean into an array located in a JSP page. Any other approaches, advice or links to information would be appreciated. Thanks...
1
by: misdst23 | last post by:
Hi, How do you include javascript in the definition of a jsp TLD. for example if i have a TLD called <mytld: body everytime I include this in a page, I also want some javascript to be included....
1
dmjpro
by: dmjpro | last post by:
Is there any term by this name exported scoped variables in JSP??? PLz explain. pageContext,page,sessionScope,requestScope r these Scoped Variables in JSP?? Kind regards, DMJPRO.
0
by: kukukgl | last post by:
Hi..... We are using velocity1.4 to implement templating in our system. The system is running fine since deploy. Recently, there is a serious problem that causing the web panel down. We did setup...
1
by: sallawari | last post by:
i got error while import a jsp File (ie).. <jsp:include page="<%=ctxName%>/run?__report=/content/report<%=reportObj.getReport(reportObj.REPORT_TYPE_BAR_GRAPH)%>" /> Error :.. ...
3
by: ajos | last post by:
Hello friends, In my action class i am getting a resultset data which im storing in a arraylist. In my jsp page im retrieving the arraylist data as-----> <%publicity.PendingReqForm prfObj=null;...
10
by: mk | last post by:
Calvin Spealman wrote: Well, basically nothing except I need to remember I have to do that. Suppose one does that frequently in a program. It becomes tedious. I think I will define some helper...
5
by: DrMalik | last post by:
Hi everyone, I hope there is somebody that can help me. I normally am programming in jsp or java, but i now have to program in javascript. I hope somebody can help me or get me in too the right...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.