Troy Peter

Greenhorn
+ Follow
since Oct 13, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Troy Peter

Rizwan,

That's it, for simple or classic tags, the <body-content> is required in the TLD. However, for the tag files, body-content (as an attribute of the tag directive) is optional and defaults to scriptless.

Troy
Rizwan,

What you just posted applies to JSP v1.1 and 1.2 and the exam is on jsp 2.0.

This appendix includes the XML Schema and DTD files for tag library
descriptors using each version of the JSP specification (from JSP 1.1 to current).



JSP.C.3DTD for TLD, JSP 1.1
The following is a DTD describing a Tag Library Descriptor file in JSP 1.1
format.



Here's jsp 2.0 relevant text on this issue from the spec:


<xsd: element name="body-content"
type="j2ee:body-contentType">
<xsd :annotation>
<xsd : Documentation>
Specifies the format for the body of this tag.
The default in JSP 1.2 was "JSP" but because this
is an invalid setting for simple tag handlers, there
is no longer a default in JSP 2.0. A reasonable
default for simple tag handlers is "scriptless" if
the tag can have a body.
</xsd : Documentation>
</xsd : annotation>



Regards,
Troy

[ October 19, 2005: Message edited by: Troy Peter ]

[ October 19, 2005: Message edited by: Troy Peter ]
[ October 19, 2005: Message edited by: Troy Peter ]
Hi Nishant,

I haven't tried that before but my guess is if you try somehow to write to the response after the forward call then nothing is going to happen (code not executed) since control will have been already transferred to the forwarded page.

Troy.
Hi Charith,

The only trusted source is either

1)you doing the implementation and seeing for yourself that it is indeed the default (meaning you don't even have to provide the body-content element in the tld and it works (don't use any IDE))
2) or showing us an extract from the jsp 2.0 specs from Sun

..otherwise, it'll be another guess just like we're doing here.
Hi all,

A question for Rizwan and Charith: do you think that the element <body-content> for a tag TLD is optional, whether it be a simple tag or classic tag?

I believe this is where you two get confused... My understanding is that this element is not optional. You have to provide it and specify either of the 3 values. This then implies that simple or classic tags don't have a default value for body-content...only a tag file can have a default value for <body-content> (scriptless). Also remember that a tag file doesn't even use a TLD for definition purpose.

Regards,
Troy
Hi,

1) Indeed, you can't have scriptlets or scriptlet expressions.

2) The valid values for body-content are empty, tagdependent and scriptless.

3) I don't think there's a default value for simple tags. I believe Rizwan is talking about tag files, where if you don't define the body-content element, then the container assumes scriptless. However, for any other custom tag, you have to have a body-content element defined.

Regards,
Troy.
Hi all,

Bhavna, setting the url-pattern that way is legal...it simply tells the container to watch for anything with extension .do.

Regards,
Troy.
[ October 15, 2005: Message edited by: Troy Peter ]
JSP
Hi Kashyap,

I think you're on the right track. Unfortunately, there's one little step you missed: tomcat 5 requires that you create a directory for your web application (referred to as the context root, or document root, used to resolve URLs). So in your case, you have Tomcat 5.0\webapps, add something like myFirstApp and move your hi.jsp file in that directory, and try again.

So, resource "hi.jsp" should be in:
C:\Program Files\Apache Group\Tomcat 5.0\webapps\myFirstApp

If this works, just remember that whenever you have a new application, you should have a "context root" directory name under webapps when working with tomcat 5 (and higher). This is all nicely explained in the HFSJ book which I'm currently reading.

Good luck,

Troy
Bosun, so much trouble indeed...

You can't have a slash when using <url-pattern>*.do</url-pattern>.
Rather Ratna should not have a slash in the html form action.

Regards,
Troy.
18 years ago
Hi Ratna,

I strongly suggest you take out the / in your form action attribute and try again. If you look in you browser url, you'll find 2 slash before valid.do.

Good luck,

Troy.
[ October 14, 2005: Message edited by: Troy Peter ]
Hi Luke, hi Mat,

Mat just gave a very good answer to your question. I'd like to add that the class Foo.Bean should be a collection for the tag c:forEach to work.

Regards,
Troy.
Hi Mannu, hi Mat,

I totally agree with Mat reply. So the answer to that mock question would be 2).

This is my understanding of what happens:
This: <jsp:useBean id=�name� class=�java.lang.String� />
translates to:
java.lang.String name = new java.lang.String();

This: <%= name %>
translates to:
out.print(name);

Since name is an empty string, then the output is empty.

Regards,
Troy
Hi Bhavna,

The great HFSJ book also has errors. Thankfully there's an errata page...please consult it whenever you think the book is not making sense.

Here's the link:
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed

Good luck,
Troy
JSP
Hi Kashyap,

I'm assuming you're using Tomcat 4.1. Please use Tomcat 5.0. This is the version that implements specs Servlet 2.4 and JSP 2.0 which is what's covered for the SCWCD.

I'm guessing that expression language (EL) was not part of the previous specs so your server is not aware of them and cannot evaluate ${...}.

Good luck,

Troy