• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Xml equivalents

 
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?
 
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...
 
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?
 
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 ]
 
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.
 
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
 
Author
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
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!!!
 
It means our mission is in jeapordy! Quick, read this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic