• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsp implicit variable

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements are correct
Select 2 correct options.

a.The implicit variable session can be used to store values needed by other servlets or JSPs of the same web application.

b.The implicit variable request can be used to store values needed by other servlets or jsps across multiple requests.

c.You can use the implicit variable response to set the content type of the output.

d.The implicit variable out is same as returned by response.getWriter()

E.All JSPs have access to request, response and session variables.

I have found this question from Enthuwere.My answer is D and E.because all the jsp pages is have Session ,request and response as implicit variable.But they marked A and D is the Answer .Please any body clear me the doubt.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that it is not E, because you can set the "session" to false in the "page" directive, in which case the "session" object will not be accessible. Why did you discard "a" ?
[ November 26, 2007: Message edited by: Christophe Verre ]
 
naresh govindaswmay
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
[URL=<%@ page session="true" %>]<%@ page session="true" %>[/url] is the default rite.why should we take this is consideration here.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why should we take this is consideration here.


Yes it's the default, but this question is not about what happens when the default value is set. You have to consider any possibilities, and setting "session" to false means that not all JSPs have access to it. The question is about all JSPs, not only JSPs whose default setting is used.
 
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And about the 'a' option does the session object store values only for the servlets and jsp's of one web application cant they share there values stored with the servlets and jsp's of a different app on different JVM where the session object travel from one JVM to another?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a.The implicit variable session can be used to store values needed by other servlets or JSPs of the same web application.
MY ANS: YES. session is a means for sharing information. provided that JSPs did not disable the session.
b.The implicit variable request can be used to store values needed by other servlets or jsps across multiple requests.
My ANS: NO if ("multiple requests" = multiple request from browser).for each client request container creates a new request and response object. You can use the same request object to pass on information when used with request dispatcher.
c.You can use the implicit variable response to set the content type of the output.
My ANS: YES
d.The implicit variable out is same as returned by response.getWriter()
My ANS: response.getWriter returns java.io.PrintWriter and out is a type of javax.servlet.jsp.JspWriter. So they are not same.
E.All JSPs have access to request, response and session variables.
As Christophe rightly said, if session is disabled by default, session will null. So answer is NO.
reply
    Bookmark Topic Watch Topic
  • New Topic