File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes For all SCWCD guys : Doubts 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 "For all SCWCD guys : Doubts" Watch "For all SCWCD guys : Doubts" New topic
Author

For all SCWCD guys : Doubts

Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
Hi All,

1. Servlet Spec says : After sendError() or sendRedirect() anything written to ( out.println() ) is ignored . There is no exception thrown . So why all the mock exams say it will give IllegalStateException . Also what happens if write something after forward() ?

I tried all these and tomcat doesn't give any error ( not in logs also ).
Can you give me the solution for above 3 scenarios ?

2. In JSP 2.0 tld file has to have <body-content> tag . It has become mandatory . This is what HF Servlets and JSP also say . Is it true ?
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
No one can reply to this ???
Ranjit Jana
Ranch Hand

Joined: Feb 17, 2005
Posts: 30
Hi ,
Please check the earlier messages and you will get the answer.

The answer is when the response is committed that means you have already sent something to the browser . In this case even if the exception is thrown it will be just logged in some tomcat specific log.

The answer is the IllegalStateException will be thrown but the browser will not know that.
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
I think u didn't read the question properly . The spec says it is ignored and also there are no exception in the logs of tomcat .
Ranjit Jana
Ranch Hand

Joined: Feb 17, 2005
Posts: 30
check this link. (advice-check previous messages before posting)

http://www.coderanch.com/t/169085/java-Web-Component-SCWCD/certification/HttpServletResponse-IllegalStateException
Ranjit Jana
Ranch Hand

Joined: Feb 17, 2005
Posts: 30
on the question on body-content please refer the dtd it specifies


<!ELEMENT tag (name, tag-class, tei-class?, body-content?, display-name?,
small-icon?, large-icon?, description?, variable*, attribute*,
example?) >

-----

That means body-content is still optional. well this is in 1.2 specification. Correct me If you are using another specification.

You can add your comment on how it works in different specification .

------------

I am adding the 1.1 specification where the whole elements itself were different

<!ELEMENT tag (name, tagclass, teiclass?, bodycontent?, info?, attribute*) >
You need not know 1.1 for the exams
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
I am refering for JSP 2.0 for <body-content> .
Please let me know ....
Ranjit Jana
Ranch Hand

Joined: Feb 17, 2005
Posts: 30
some of the examples I went through had the following as dtd


http://java.sun.com/dtd/web-jsptaglibrary_2_0.dtd

if anyone of you can get this dtd let me know . I am not aware where can we get this dtd. Till then I assume 1.1 is the latest.
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
I clicked that link .But Page cannot be found ??

Its XSD and not dtd
Ranjit Jana
Ranch Hand

Joined: Feb 17, 2005
Posts: 30
Ok I got what you were looking for its a schema definition.

Look at
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd
so this is the answer .

body-content is still required as minOccurs="0" only for the optional elements

--------------


- <xsd:complexType name="tagType">
+ <xsd:annotation>
<xsd ocumentation>The tag defines a unique tag in this tag library. It has one attribute, id. The tag element may have several subelements defining: description Optional tag-specific information display-name A short name that is intended to be displayed by tools icon Optional icon element that can be used by tools name The unique action name tag-class The tag handler class implementing javax.servlet.jsp.tagext.JspTag tei-class An optional subclass of javax.servlet.jsp.tagext.TagExtraInfo body-content The body content type variable Optional scripting variable information attribute All attributes of this action that are evaluated prior to invocation. dynamic-attributes Whether this tag supports additional attributes with dynamic names. If true, the tag-class must implement the javax.servlet.jsp.tagext.DynamicAttributes interface. Defaults to false. example Optional informal description of an example of a use of this tag tag-extension Zero or more extensions that provide extra information about this tag, for tool consumption</xsd ocumentation>
</xsd:annotation>
- <xsd:sequence>
<xsd:group ref="j2ee escriptionGroup" />
<xsd:element name="name" type="j2ee:tld-canonical-nameType" />
+ <xsd:element name="tag-class" type="j2ee:fully-qualified-classType">
- <xsd:annotation>
<xsd ocumentation>Defines the subclass of javax.serlvet.jsp.tagext.JspTag that implements the request time semantics for this tag. (required)</xsd ocumentation>
</xsd:annotation>
</xsd:element>
+ <xsd:element name="tei-class" type="j2ee:fully-qualified-classType" minOccurs="0">
- <xsd:annotation>
<xsd ocumentation>Defines the subclass of javax.servlet.jsp.tagext.TagExtraInfo for this tag. (optional) If this is not given, the class is not consulted at translation time.</xsd ocumentation>
</xsd:annotation>
</xsd:element>
- <xsd:element name="body-content" type="j2ee:body-contentType">
- <xsd:annotation>
<xsd ocumentation>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 ocumentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="variable" type="j2ee:variableType" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="attribute" type="j2ee:tld-attributeType" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="dynamic-attributes" type="j2ee:generic-booleanType" minOccurs="0" />
+ <xsd:element name="example" type="j2ee:xsdStringType" minOccurs="0">
- <xsd:annotation>
<xsd ocumentation>The example element contains an informal description of an example of the use of a tag.</xsd ocumentation>
</xsd:annotation>
</xsd:element>
+ <xsd:element name="tag-extension" type="j2ee:tld-extensionType" minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
<xsd ocumentation>Tag extensions are for tool use only and must not affect the behavior of a container.</xsd ocumentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" />
</xsd:complexType>
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
Still I am confused . The xsd says :

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.

that means for Custom tags <body-content> is compulsory and for Simple tage its by default "scriptless" .

Please correct me if I am wrong .
Francois Roland
Ranch Hand

Joined: Jul 24, 2003
Posts: 34

About your first question, here is an excerpt from the HttpServletResponse javadoc:

It says that an IllegalStateException is thrown if the response has been commited before calling the sendError method (the same applies for sendRedirect). So, you are right when you say that no exception would be raised if you write something after one of these two method has been called.


--
Brown belt on KnowledgeBlackBelt.com.
 
jQuery in Action, 2nd edition
 
subject: For all SCWCD guys : Doubts
 
Similar Threads
Problems with jsp:include
Struts handle first request.
Implementing the User access in an application
Marcus green mock 3- method invocation
flush() method