• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Xml equivalents

 
Aleks V. Pascoal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't use the Xml equivalents of declaration, scriptles, etc. I didn't use then together with <%!..%>, etc. I am using Tomcat 4, can anyone help me?
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your page here? (strip it down a bit if its a really big page). Maybe we can help you to find a problem with it...
 
Aleks Pascoal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, my JSP is just:
<jsp:scriplet> int i = 0;</jsp:scriplet>
<%=i%>
It doesn't work, if i remove "<%=i%>", it will print " int i = 0;".
Can you help me?
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not mix XML sytax and standard JSP syntax in the same file!
Check out : http://www.javaranch.com/newsletter/Feb2002/newsletterfeb2002.jsp#feature
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aleks V. Pascoal:
I can't use the Xml equivalents of declaration, scriptles, etc. I didn't use then together with <%!..%>, etc.

Originally posted by Aleks Pascoal:
Ok, my JSP is just:
<jsp:scriplet> int i = 0;</jsp:scriplet>
<%=i%>
It doesn't work, if i remove "<%=i%>", it will print " int i = 0;".
Can you help me?

--- but you DID mix the XML equivalents together with <% %> tags :roll:
[ July 22, 2002: Message edited by: Jessica Sant ]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I'm missing something, but isn't this just a typo: it should be jsp:scriptlet.
As for not mixing XML forms and <% forms on the same page, is this really a problem? I have done this several times with Resin, and it's never complained.
 
Shashank Tanksali
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Frank pointed out, try using <jsp:scriptlet> ..... </jsp:scriptlet>
and <jsp:expression> .... </jsp:expression> instead of <%= .... %>
Shashank
 
Aleks Pascoal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still doesn't works.
My page is just:
<jsp:scriplet>int i = 0; i++; out.println(i);</jsp:scriplet>
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frank Carver:
Maybe I'm missing something, but isn't this just a typo: it should be jsp:scriptlet.
As for not mixing XML forms and <% forms on the same page, is this really a problem? I have done this several times with Resin, and it's never complained.

Aleks -- note the spelling that Frank pointed out. That should fix your problem.
Frank -- Mixing the XML syntax and <% tags is against the spec -- if Resin allows it, that's very bad -- your app won't port to another app server very easily. (See the spec: JSP.5.1 "A JSP page in either syntax can include via a directive a JSP page in either syntax. It is not valid, however, to intermix standard JSP syntax and XML syntax inside the same source file.")
 
Aleks Pascoal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean,
<jsp:scriptlet>int i = 0; i++; out.println(i);</jsp:scriptlet>
??
It still doesn't work
It prints "int i = 0; i++; out.println(i);"
Aleks
 
Jignesh Malavia
Author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aleks Pascoal:
Still doesn't works.
My page is just:
<jsp:scriplet>int i = 0; i++; out.println(i);</jsp:scriplet>

You mean you haven't used the jsp: root element at all? It has to be a complete document as
<jsp: root xmlns: jsp="http: //java.sun.com/JSP/Page" version="1.2">
<html><body>
<jsp: text>Hello</jsp: text>
<jsp: declaration>int i=1;</jsp: declaration>
<jsp: scriptlet> i++; </jsp: scriptlet>
<jsp: expression> i</jsp: expression>

</body></html>
</jsp: root>
HTH
 
Jignesh Malavia
Author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aleks Pascoal:
You mean,
<jsp:scriptlet>int i = 0; i++; out.println(i);</jsp:scriptlet>
??
It still doesn't work
It prints "int i = 0; i++; out.println(i);"
Aleks

In this case, since you have not used the jsp: root element, the JSP engine assumes it is a normal JSP page and will wrap the whole text inside out.write() as:
out.write("<jsp:scriptlet>int i = 0; i++; out.println(i);</jsp:scriptlet> ");
If you click on the "view source" menu of you browser, you will see the scriptlet there.
HTH
-j
 
Aleks Pascoal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everybody i wasn't using jsp:root....
it works!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic