Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errors on javaranch scwcd hints page?

 
Atul A. Shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Although the scwcd hints page (http://faq.javaranch.com/view?ScwcdHints) contains some very useful reminders, I was hoping someone could corroborate that a few of the hints are in fact incorrect:

#11-- says of the <jsp:include> action that
"Page attribute accepts relative and absolute URLs."

This is in contradiction to the statement in section 5.4 of the jsp specification (jsp-2_0-fr-spec.pdf, p.1-109) where it says that:
"The resource is specificed using a relativeURLspec that is interpreted in the context of the web application."
The "page" entry in Table JSP.5-4 (p.1-110) repeats that:
"The URL is a relative urlSpecf as in Section JSP.1.2.1. Relative paths are interpreted relative to the current JSP page."

The faq also says of the include directive that:
"File attribute accepts relative and absolute URLs.", which appears to be contradicted in JSP.1.10.3 (p.1-51).

#14-- "A web.xml file that contains only an empty root element (<web-app></web-app> is perfectly legal."
is contradicted in section SRV.13.4 of the servlet spec (p.135 of servlet-2_4-fr-spec.pdf) where it says that:
"[The web-app] element has a required attribute "version"..."

#33-- Lists 4 steps in the creation of a custom tag.
Step 3, "Tell in the web.xml file about where to find the TLD file",
is not strictly necessary, since the specification defines a process whereby jsp containers automatically discover any .tld files within WEB-INF or a subdirectory (JSP.7.3.4, p.1-162).

Do you agree?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#14 Agree. The statement is correct, but the example is not. It should be <web-app version="2.4"></web-app>.
#33 Agree. There's no need to edit web.xml.
#11 Difficult to say. By absolute, he probably wanted to refer to url starting with "/". This should be called "context relative". If it does not start with "/", it should be called "page relative". But I agree that it should be clearly written in the hints page.

If Jothi (who is making this hint page) is not around, I'll fix them.
 
Atul A. Shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christopher.

I also wonder about hint #2:
"A <jsp:forward> effectively terminates the current page. Nothing before the <jsp:forward> or after the <jsp:forward> is written to the response! It is not the same when using a requestDispatcher.forward()."

Regarding requestDispatcher.forward(), SRV.8.4 states "If output data exists in the response buffer that has not been committed, the content must be cleared [by the container] before the target servlet's service method is called."...
"Before the forward method of the RequestDispatcher returns, the response content must be sent and committed, and closed by the servlet container."

These two statements together suggest that nothing before or after the forward method call is written to the response, just as with <jsp:forward>.

Is there any difference in the mechanics of the two approaches? Parameters sent to <jsp:forward> with <jsp aram> are equivalent to query string parameters appended to the resource name passed to the RequestDispatcher. <jsp:forward> can forward to a context-relative URI, just like the RequestDispatcher retrieved from a ServletRequest. I'm inclined to think that <jsp:forward> uses the RequestDispatcher to perform its forwarding. What do you think?
 
Atul A. Shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correction: <jsp:forward> and RD.forward() (from ServletRequest) can accept both context-relative and page-relative paths.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for the corrections. Though it came in very late, it will be useful for future exam takers...Thanks once again for the cooperation.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've committed the changes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic