Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Something Unusual. Why is it so?

 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you review the getter methods for PageContext it should become clear.
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

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

Regards,
Khushhal
 
nagalatha mitta
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic