• 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

Something Unusual. Why is it so?

 
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

for JSP

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>

<html><body>

Session Id : ${pageContext.session.id} <br>
Request URI: ${pageContext.request.requestURI} <br>
Buffer Size: ${pageContext.out.bufferSize}<br>
Servlet Info: ${pageContext.page.servletInfo}

</body></html>



Output is

Session Id : 5DA13B2D9E4EA9F5AE7C3C42EBA5BCF4
Request URI: /SCWCD/result.jsp
Buffer Size: 8192
Servlet Info: Jasper JSP 2.0 Engine



Butttt..


For JSP

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<html><body>

Server Info: ${pageContext.application.ServerInfo}

</body></html>



Output is

exception

javax.servlet.ServletException: Unable to find a value for "application" in object of class "org.apache.jasper.runtime.PageContextImpl" using operator "."
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)



And For JSP

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<html><body>

Servlet Name: ${pageContext.config.ServletInfo}

</body></html>



Output is

exception

javax.servlet.ServletException: Unable to find a value for "config" in object of class "org.apache.jasper.runtime.PageContextImpl" using operator "."
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825




Please let me know why is it so. They are also the implicit objects.


Regards,
Khushhal
 
khushhal yadav
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there is one mistake. But that's not the cause of problem.

Server Info: ${pageContext.application.ServerInfo}
will be
Server Info: ${pageContext.application.serverInfo}

and

Servlet Name: ${pageContext.config.servletInfo}
will be
Servlet Name: ${pageContext.config.servletInfo}

That's something, I comitted while posting.

Even
${pageContext.config}
${pageContext.application}
don't work

while
${pageContext.session}
${pageContext.request}
${pageContext.page}
${pageContext.out}
work

Regards,
Khushhal
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you review the getter methods for PageContext it should become clear.
 
khushhal yadav
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankyou Marc.

I got it.
Marc, one more query.
What difference include(String, flush) makes to the output?
What's its utility?
Is it just to prevent the overflow of buffer?
As the buffer is flushed to the output as soon as we give a dynamic call for the response to the included page by doing
<jsp:include page="/header.jsp" flush="true">
Or there is some other difference or significance too?
But there won't be any difference in output. Except if some Exception is raised.Is it so?

Regards,
Khushhal
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The more important question is "What does flush mean?"

A flush means to start sending everything you've got (so far) to the browser. This can help to make a page appear more responsive to the user because they have to wait less time before they start to see stuff display.
 
khushhal yadav
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,

That's the only thing.
Or does it makes some other difference also?

Regards,
Khushhal
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi khushhal
please let me know what changes you made to your jsp code to get the output because even iam getting the same output as you got.

Servlet Info: ${pageContext.page.servletInfo}
Server Info: ${pageContext.ServletContext.ServerInfo}.
what changes you made to above code?
 
khushhal yadav
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nagalatha,

Instead of writing ${pageContext.ServletContext.ServerInfo}
you write ${pageContext.servletContext.serverInfo}
First letter must be a small letter.
All bean conventions.

Regards,
Khushhal
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic