• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two questions on " JSP SYNTAX 1.2 " issued by SUN

 
Peter Wei Cai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1, "Spaces are not allowed between an equals sign and an attribute value".
I do not understand its meaning. Can anybody show me an example?

2, "JSP and XMl syntax can not be mixed within a page".
below are some JSp code. which are right?
I choose a, c; How about your idea?

a>
..................
<%! int i=0; %>
<%! int j=0; %>
<% out.println(i); %>
<% out.println(j); %>
......
b>
..................
<jsp eclaration> int i=0; </jsp eclaration>
<%! int j=0; %>
<% out.println(i); %>
<% out.println(j); %>
......

c>
..................
<jsp eclaration> int i=0; </jsp eclaration>
<jsp eclaration> int j=0; </jsp eclaration>

<% out.println(i); %>
<% out.println(j); %>
......
d>
..................
<jsp eclaration> int i=0; </jsp eclaration>
<%! int j=0; %>
<jsp:scriplet> out.println(i); </jsp:scriplet>
<% out.println(j); %>
......
 
Charles Scherer
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your first question about spaces in an expression, the following is incorrect:
<% = expression %>
to correct it, remove spaces before and after the equals:
<%=expression %>
 
Tong Chen
Ranch Hand
Posts: 1011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not valid to mix standard syntax and XML syntax in the same source file.
So any a) is correct.
 
Tong Chen
Ranch Hand
Posts: 1011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the typo...
It is not valid to mix standard syntax and XML syntax in the same source file.
So only a) is correct.
 
Peter Wei Cai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the first question:
<%=expression> is absolutely right.
But how about:
<%= expression>
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter, You should download a copy of Tomcat and try out these types of questions. IMO, the hands on experience will help you understand these little rules far more clearly. Just a suggestion!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic