Anoopriya Muthuswaami

Greenhorn
+ Follow
since Nov 20, 2008
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 Anoopriya Muthuswaami

Thanks Kengkaj. Do you have any idea of SOAP versions. Is it ok if I study SOAP 1.1 covered in RMH and then read the difference between SOAP 1.1 and 1.2?
Also the XML schema version in RMH is 1.0 whereas in SCDJWS is 2.0.
I have read all the previous posts on books to follow for SCDJWS 5 but am still confused.
Most of them have suggested RMH book but it deals with J2EE 1.4 API.
The web service standard covered in RMH are
• XML 1.0
SOAP 1.1
• SOAP Messages with Attachments
• WSDL 1.1
• UDDI 2.0
WS-I Basic Profile 1.0
• JAX-RPC 1.1
• SAAJ 1.2
• JAXR 1.0
• JAXP 1.2

But SCDJWS deals with SOAP 1.2 and WS-I Basic Profile 1.1. Not sure of version for others.

Is it enough to follow RMH book or is there any book on EE 5?

Please help me on this
Its better to start learning without IDE. Manually deploy classes and write DD.

Once you have got the concept, then may be you can switch to IDE.
If the body-content is declared as 'JSP' or 'scriptless' in TLD, it can still be used in JSP as a tag with no body.
Eg:
<body-content>JSP</body-content>

JSP:
<my:tag2/> is still valid.

Since the body-content is declared as one other than empty, it is not mandatory to declare the tag with a body.

Hope this clears your doubt.

I read Head First Servlets and JSP book.
Solved mock exams from javaranch, examulator, javaprepare.
Real exam was pretty easy. All the best to all ranchers who are you going to take up the exam.
Today I cleared SCWCD with 100%. This forum was very helpfull for me in preparing for the exam. Thanks to all the ranchers.
HFJS reads as "If the Container can�t locate the right resource for the request, the filter is never invoked".

But I had the following entry in web.xml
<filter>
<filter-name>LoginCheckFilter</filter-name>
<filter-class>example.LoginCheckFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>LoginCheckFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

There are NO servlet mapping for *.do.

When I typed the following in brower, http://localhost:8080/ExampleWebProject/Test.do , I get the Http 404 error page(expected) but I can see the doFilter() being invoked.

Can someone clarify me on this?
TagHandler:
public class TextTag extends TagSupport{

public int doStartTag() throws JspException {
return EVAL_BODY_INCLUDE;
}

}

TLD:
<tag>
<name>Text</name>
<tag-class>example.TextTag</tag-class>
<body-content>tagdependent</body-content>
</tag>

JSP:
EL <nw:Text> ${"hello"}</nw:Text> <br>
Scriplet <nw:Text> <%= "hello" %></nw:Text><br>
JSTL <nw:Text> <c ut value="hello"/> </nw:Text><br>
PlainText <nw:Text> Hello</nw:Text><br>

Output:
EL ${"hello"}
Scriplet
JSTL
PlainText Hello

as per my understanding, if body-content is tagdependent, everything(EL,scriptlet,std action, JSTL) are treated as plain text and the same will be printed to the response/browser.

My question is when EL gets printed, why not scripltet and JSTL action <c ut>

I expected the following output
EL ${"hello"}
Scriplet <%= "hello" %>
JSTL <c ut value="hello"/>
PlainText Hello

Please clarify me on this.
There were many thread in this forum related to default value of body-content.

I tried few examples and have following question

If spec says <body-content> is mandatory, how am I be able to run custom tag without <body-content> in TLD

CASE 1:
Custom tag extends SimpleTagSupport
no <body-content> mentioned in TLD

Result:
HTTP status 500
The TLD for the class example.TextTag specifies an invalid body-content (JSP) for a SimpleTag.

This means by default it takes JSP as default value for body-content. Since SimpleTags cannot have scriptless, it says "JSP" is not a valid body-content.

CASE2:
Custom tag extends TagSupport
no <body-content> mentioned in TLD
JSP had expression within body of tag

Result:
Expression in body of tag got evaluated.

When expression got evaluated, it means <body-content> is JSP

Please clarify me on this.
TLD:
<body-content>JSP</body-content>

JSP:
<prefix:tagName>Hello</prefix:tagName>

Case 1:

Tag Handler:
public class TextTag extends BodyTagSupport{


public int doStartTag() throws JspException {
return EVAL_BODY_INCLUDE;
}


public int doAfterBody() throws JspException {
try {
pageContext.getOut().print("How are you?");
}catch(IOException e) {}
return SKIP_BODY;
}
}

Output:
Hello How are you?

Case 2:

Tag Handler:
public class TextTag extends BodyTagSupport{


public int doStartTag() throws JspException {
return EVAL_BODY_BUFFERED;
}


public int doAfterBody() throws JspException {
try {
pageContext.getOut().print("How are you?");
}catch(IOException e) {}
return SKIP_BODY;
}
}

Output:
Nothing gets printed.

If I add the following code, �Hello How are you?� gets printed
JspWriter out = getBodyContent().getEnclosingWriter();
out.print(getBodyContent().getString());
out().print("How are you?");

What is the difference between pageContext.getOut and JspWriter got from getEnclosingWriter()? The behavior differs only when I return EVAL_BODY_BUFFERED from doStartTag().
Can someone please explain me the concept.

Originally posted by Ankit Garg:
Julian can you please Quote Your Source...



Its from http://www.javaranch.com/carl/SCWCD.htm
Which statements are correct about exceptions in servlets?

1) If there is defined an error page for an exception and a servlet included through a RequestDispathcer generates an exception, the standar mechanism of calling that error page is not used, so the calling servlet can process the excpetion.
2) The element in the DD used to specify where the error page can be found is: <url-pattern>
3) If a servlet generates an exception not defined in a error page then the servlet container sets the response status 500
4) If a servlet generates a ServletException or subclass and no match is found in the error pages defined in the DD then, the servlet container tries again to find a match with the wrapped exception which is obtained by calling ServletException.getRootCause().

Answer 1,3,4
I understand option 2 is incorrect and option 3,4 is correct. Can someone explain option 1.
[ December 11, 2008: Message edited by: Julian Justin ]

Originally posted by Christophe Verre:

Which test ? Please quote your sources.



It was a mock exam http://www.javaranch.com/carl/SCWCD.htm
Which statements are true about the Web Application DD

1) There can't be leading nor trailing spaces for PCDATA whithin text nodes
2) The servlet container must ensure that role-names in auth-constraint are defined in security-role elemen
3) URI paths specified are assumed to be URL decoded form
4) None of the above

Answer mentioned in the test was 3.

I did not understand option 3. But I think option 2 is correct.
Can someone explain all 3 options?
Which statements are true about distributable web applications

1) There will be one instance of ServletContext in each VM
2) There will be only one instance of the default ServletContext in only one VM(the default ServletContext is one created for all servlets not deployed as part of an application are assigned)
3) All request that are part of a session must be handled by one VM at a time
4) Container must notify any session attributes implementing the HttpSessionActivationListener interface during migration of a session from one VM to another

Answer: 1,2,3,4

I can understand options 1,3 and 4 and know they are true.
Can anyone explain option 2