This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about jsp expression

 
jeffrey z. lee
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will be the result of this jsp line if the user takes a look at the page source code?
<!-- Today is <%= new java.util.Date() %>.Hava a nice day -->
 
Raj Paul
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wont see the output but the date will be evaluated.
 
Dave Thomas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I think you will see the output and the date will be evaluated - These (<!--) are just html comments. "<%--" will prevent the line being displayed "in the source code"
 
Kyle Tang
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why there is no output? <!-- is not jsp comments, it is for XML comments. I think there should be outputs.
 
Raj Paul
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the evaluated string is included in output, but the browser wont detect that, because it is inside <!-- --> XML & HTML comment.
Raj Paul
 
Kyle Tang
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good, the original jsp defaults the content type to "text/html", so the output is commented out. in order to see the output one has to set the content type to text/plain.
 
Dave Thomas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I don't think that's right. Sure you wont see the output in the browser but the question asks if it will be visible in the source code (Edit menu > view source). It is. Just to make sure I tested it - without setting the content-type - and it is.
 
jorge zapata
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you add the code
<!-- Today is <%= new java.util.Date() %>.Hava a nice day -->
to your jsp and run it. the code will be viewable if you right click on the page and do a view source. however, the viewer will not be able to see any output to the jsp page
 
Paul McKenna
Ugly Redneck
Ranch Hand
Posts: 1006
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I tried the above in JRUN 4.0 which is JSP 1.2 compliant and the result was I could not see any output on the browser, but when I right clicked and viewed source I noticed that the JSP compiler had translated the Date object. No Source code was visible.
Another strange thing was that I tried the same using the XML syntax <jsp:expression>... and it did not work in JRUN 4.0. Gave me an error message stating "The tag expression is not defined in the tag library...."
Any clues?
SR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic