• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

XML syntax for jsp

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is following a valid jsp syntx ?<jsp:expression>output</jsp:expression>
shouldn't the word output be enclosed in quotes ?
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there is a variable named as output defined before this (either as a scriptlet var or as a declaration var) , this code will work fine. Meaning the value of a varibale 'output' will be written to JspWriter.
For example the following jsp will work fine.

If there is no variable defined before, then we will get a compilation error.
If we just want to get this String "output" itself to browser then we can code like this .
<jsp:expression>
"output"
</jsp:expression>
Regards,
Maha Anna
[ December 13, 2002: Message edited by: Maha Annadurai ]
 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
version="1.2">
<jsp:scriptlet>
String output ="Hello World!";
</jsp:scriptlet>
<jsp:expression>
output
</jsp:expression>
</jsp:root>
I think, in above code, output should be enclosed in %= output %, because this is a request time attribute expression.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The above code has got a valid jsp expression. Note that it is NOT a request time attribute expression. A request time attribute expression is something like this.

Regards,
Maha Anna
[ December 16, 2002: Message edited by: maha anna ]
 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
got it, thanks.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if your intent is to print the word "output" you could also use the <jsp:text> tag...
<jsp:text>output</jsp:text>
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A) JSP expression add some data to the output stream.
XML style:
<jsp:expression> other </jsp:expression>
JSP style:
<%= other %>
-> adds the value of variable other to output stream.

B) Request time attribute expressions allow to pass dynamic values to actions like jsp:include, beans or custom tags.
XML style: "%= other %"
example: <jsp:include page="%= pageURL %" />
JSP style: "<%= other %>"
example: <jsp:include page="<%= pageURL %>" />
-> passes the value of variable other ot include action.

So JSP style uses <%= ... %> in both cases.
Hope this helps,
Bernd
SCJP
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic