Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

tony lee

Ranch Hand
+ Follow
since Jan 21, 2002
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 tony lee

hi,
i guess the code of C.jsp is inserted into B.jsp whose code is eventually added into A.jsp. System.out.println("THIS METHOD CALLED ") is executed for two times?
I'm confused here
Hi,
Could someone tell me what the difference between
HttpServletResponse.endcodeURL and HttpServletResponse.endcodeRedirectURL ?
Hi,
I need a help. The following is a question:

what will be printed out by the following part of a jsp page?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
1) The tag handler won't compile.
2) The jsp page will print Hello how are you?
3) The jsp page will print how are you? Hello
4) The jsp page will print Hello
Answer is 4.
Could someone try it on your machine? I tried and found the right answer should be 1


avax.servlet.ServletException: Since tag handler class util.body does not implement BodyTag, it can't return BodyTag.EVAL_BODY_TAG ...


Thanks,
Hi,
I tried this code, and it runs fine. If you want to print a note, please try this:
Hi friends,
I tried two handler classes: One implementing TagBodySupport and another TagSupport.
code 1

code 2

The JSP file including code:
<utile:my>
<i>Hello</i>
</utile:my>
With code 1, browser print Hello
With code 2, there's an exception like
javax.servlet.ServletException: (class: org/apache/jsp/$2_0005f5$jsp, method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V) Incompatible object argument for function call ...
Could someone tell me why?
Thanks,

The default doStartTag() returns EVAL_BODY_BUFFERED.


I tried by adding a doStartTag() which returns EVAL_BODY_INCLUDE, then it print "Hello how are you." We can find the return value matters.
What does EVAL_BODY_BUFFERED mean
Hi,
The difference is that HttpSessionBindingListener can be implemented to notify any object, while HttpSessionAttributeListener is only used for attribute list.
Given the following tag handler defined with <bodycontent>JSP</bodycontent>
public class body extends TagSupport {
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;
}
}
what will be printed out by the following part of a jsp page?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
1) The tag handler won't compile.
2) The jsp page will print Hello how are you?
3) The jsp page will print how are you? Hello
4) The jsp page will print Hello
The answer is 3. I think it should be 2
Hi,
Is anybody know which methods - doStartTag(), doEndTag(), doBodyTag(), are mandatory to a handler class? Why?
Thanks,
I have problems with nested stuff , like nested scripting, nested actions, ...
Could anyone tell me about the principle there?
Hi,
It's my version:
On startup of webapp
##load the servlet class
##instantiate the class
##call init
##call contextInitialized - if ServletContextListeners is declared in DD.
when there is a request
##call service -> (doGet, doPost)
##HttSession ses = request.getSession() - use the existing session or create one if necessary.
##call sessionCreated() - if the class implement HttpSessionListener.
##call sessionDidActivate() - if the class implement HttpSessionActivationListener.
##call other listener methods if any session listener interfaces are implemented.
on shutdown
##destroy
##sessionDestroyed, sessionWillPassivate? ..
##contextDestroyed
Sorry, I just add on the author's message.
Hi Andy,
You gave a few interesting examples. Thanks.


for 2. How about I give an example of useBean scope:
<% { %>
<jsp:useBean id=test ..../>
....
<% } %>
....
will the test bean outside the { } scope.


In the case I think the test bean is only available to the local {}, no mater what scope has been declared, right?

for 3. I don't think the session.invalide() will call when we shut down the web-app, instead HttpSessionActivationListener.willPassivate() will call.


Shall we need to impliment HttpSessionActivationListener manually, or container automatically does that for us?

for 4. can we do something like this:
<jsp:useBean id= .... value='<eg:egtag attr="test"/>'/>


I know we can use a request time attribute value like "<%= scriptlet_expr %>" or '<%= scriptlet_expr %>'. Could we use custom tag expression
Whenever we use sigle quotes or double quotes, I think the principle is making no intersections of the quotes, right?
In this way, '..".."..' is equivalent to "..'..'.."
Given:
<jsp:useBean id="temp"
class="java.lang.String" />
<% temp="temp";
out.println(temp); %>
What is the output?
A) temp
B) empty
C) ServletException
D) null
A is correct choice.
I think var temp in <% temp="temp";
out.println(temp); %> is not defined. How does it work

Could you be more specific about your problem, error codes


The problem is:
When I type in http://localhost:8080/my.html into the browser, a window "Unknown File Type" is prompted. But I can open my.html as a common file
Thanks,
Hi guys,
I don't know why my tomcat4.0 doesn't work well:
I can't read html files from browser.
It used to do well, but not now. Anyway, it still is fine with jsps and servlets.
Could someone tell me why?
Thanks,