• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Session handling in Jsp

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

How session is handled in jsp ? A interviewer asked me this question.What exactly he meant by this question?
I answered as session is implicit object ,So it will automatically avaliable.or if we make session=false.it will not participate in the session.Does i made any sense.

Thanks in advance
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe that the interviewer was looking for how sessions are maintained by the container.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I *think* he means to ask about Session Management in JSP:
By default, all JSP pages participate in HTTP session.
The HttpSession object can be accessed within scriptlets through the session implicit JSP object.(This is what you replied...Extention to that:)
Sessions are a good place for storing beans and objects that need to be shared across other JSP pages and servlets that may be accessed by the user.
The session objects is identified by a session ID and can be stored in the browser as a cookie.
You can store any valid Java object by identifying it by a unique key like this:
<%
Test test=new Test();
session.setAttribute ("test",test);
%>
And you can retrieve it on all JSP pages:
<%
Test newTest= (Test) session.getAttribute ("test");
%>
I am not sure but this might be the answer...
Yeah right..my mistake..
 
Sarath Koiloth Ramath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the replies ..
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rujuta gl wrote:
<%
Test test=new Test();
session.putValue("test",test);
%>
And you can retrieve it on all JSP pages:
<%
Test newTest= (Test) session.getValue("test");
%>


Just a little info, putValue and getValue are replaced (deprecated) by setAttribute & getAttribute methods as of servlet 2.2 spec.
 
Sarath Koiloth Ramath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I aswered llike that.but they were not happy with that...I dont know why ..?Any way thanks for the replies....
 
Yeah, but is it art? What do you think tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic