GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Something Unusual. Why is it so? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Something Unusual. Why is it so?" Watch "Something Unusual. Why is it so?" New topic
Author

Something Unusual. Why is it so?

khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

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


rgrds,
Khushhal
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

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

Joined: Feb 05, 2003
Posts: 4727

If you review the getter methods for PageContext it should become clear.


A good workman is known by his tools.
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

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

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Jun 20, 2007
Posts: 242

Mark,

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

Regards,
Khushhal
nagalatha mitta
Greenhorn

Joined: Jun 11, 2007
Posts: 26
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

Joined: Jun 20, 2007
Posts: 242

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
 
GeeCON Prague 2014
 
subject: Something Unusual. Why is it so?