This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
What is the output of the servlet code below assuming that the surrounding code would be valid? out.println("<%=new date()%>");
The answer is: <%=new date()%> is printed. I was thinking there should be a backslash between <% and %> to escape the sequence..... Am I missing something? Thanks. - satya
you are right Satya! It throws a compilation error saying : String not terminated at end of line. out.println("<%=new date() Need a / between % and > at the end for successful compilation : out.println("<%=new date()%/>"); Even that prints : <%=new date()%/> Any idea how to print : <%=new date()%> ? -Srini
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
posted
0
Any idea how to print : <%=new date()%> ?
I think I read somewhere in the Specs that you need to escape it. So I am assuming that out.print("<\%=new date()%\>") would work. I haven't tried it yet. regds. - satya
Thanks for pointing that out, it is a bit ambiguous. 'String not terminated at end of line. out.println("<%=new date()' is the result when the code is used in a JSP page. However in a Servlet the output is: <%=new date()%> as '<' and '%' are not special characters in Servlets in the same sense as in JSP. The abovementioned was tested Tomcat 4.0. Do you have other experiences with the output? In what environment are you testing this?
Originally posted by Madhav Lakkapragada: Any idea how to print : <%=new date()%> ?
<%=new date()%> should do the job. The spec says the output of the expression will be converted to a String and included in the response. Am I missing something :roll:
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
posted
0
as '<' and '%' are not special characters in Servlets in the same sense as in JSP aha! So this is okay in Servlets and not in JSP. Thanks. Ajith: Pl. check with Mika's post above. I haven't tried it yet, I am using Tomcat 4.0.1 regds. - satya
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: JSP output with lessthan % symbol ? - Mika's mock