You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Luke Vanderfluit <lu...@chipcity.com.au> on 2003/09/09 05:52:20 UTC

using xml in jsp files

Hi,

I'm a student learning about JSP and servlets,
I currently have some example JSP files that run OK using the <% %>
tags, but won't run when using <jsp:expression></jsp:expression> tags

I have 2 files taken from a book by Dustin Callaway, 
simple.jsp --> works fine
-=-=-=-=-=-=-=-=-=-=-=-=-
<HTML>
<HEAD>
<TITLE>Simple JSP Page</TITLE>
</HEAD>
<BODY>
<H2>Request Origin</H2>
Host Name: <%= request.getRemoteHost() %>
<BR>
IP Address: <%= request.getRemoteAddr() %>
</BODY>
</HTML>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
simple_xml.jsp --> doesn't work
error: org.apache.jasper.JasperException: jsp.error.data.file.read
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE root PUBLIC "-//Sun Microsystems Inc.//DTD Java Server Pages
Version 1.1//EN"
"http:/java.sun.com/products/jsp/dtd/jspcore_1_0.dtd">

<jsp:root xmlns:jsp="http://java.sun.com/products/jsp/dtd/jsp_1_0.dtd"
version="1.2">

<%@ page errorPage="simple.jsp" %>

<HTML>
<HEAD>
<TITLE>Simple JSP Page</TITLE>
</HEAD>
<BODY>
<H2>Request Origin</H2>
Host Name:
<jsp:expression>request.getRemoteHost()</jsp:expression>
<BR>
IP Address:
<jsp:expression>request.getRemoteAddr()</jsp:expression>
</BODY>
</HTML>
</jsp:root>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

any ideas why the XML is not working?
I'm using 
Redhat 9, tomcat 4.1.27, java sdk 1.4.2
Apparently tomcat 4.x complies with jsp spec 1.2, which as far as I can
see includes the XML syntax used above. 

thanks,
kind regards,
Luke

-- 
====================================
"when my computer smiles, I'm happy"
===============================.~ ~,
Luke Vanderfluit               |'/']
Mobile: 0421 276 282            \~/`


Re: using xml in jsp files

Posted by Tim Funk <fu...@joedog.org>.
YOu can't intermix <% %> and xml syntax. YOu can use one or the other, but 
not both at the same time.

-Tim

Luke Vanderfluit wrote:

> Hi,
> 
> I'm a student learning about JSP and servlets,
> I currently have some example JSP files that run OK using the <% %>
> tags, but won't run when using <jsp:expression></jsp:expression> tags
> 
> I have 2 files taken from a book by Dustin Callaway, 
> simple.jsp --> works fine
> -=-=-=-=-=-=-=-=-=-=-=-=-
> <HTML>
> <HEAD>
> <TITLE>Simple JSP Page</TITLE>
> </HEAD>
> <BODY>
> <H2>Request Origin</H2>
> Host Name: <%= request.getRemoteHost() %>
> <BR>
> IP Address: <%= request.getRemoteAddr() %>
> </BODY>
> </HTML>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> simple_xml.jsp --> doesn't work
> error: org.apache.jasper.JasperException: jsp.error.data.file.read
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE root PUBLIC "-//Sun Microsystems Inc.//DTD Java Server Pages
> Version 1.1//EN"
> "http:/java.sun.com/products/jsp/dtd/jspcore_1_0.dtd">
> 
> <jsp:root xmlns:jsp="http://java.sun.com/products/jsp/dtd/jsp_1_0.dtd"
> version="1.2">
> 
> <%@ page errorPage="simple.jsp" %>
> 
> <HTML>
> <HEAD>
> <TITLE>Simple JSP Page</TITLE>
> </HEAD>
> <BODY>
> <H2>Request Origin</H2>
> Host Name:
> <jsp:expression>request.getRemoteHost()</jsp:expression>
> <BR>
> IP Address:
> <jsp:expression>request.getRemoteAddr()</jsp:expression>
> </BODY>
> </HTML>
> </jsp:root>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> 
> any ideas why the XML is not working?
> I'm using 
> Redhat 9, tomcat 4.1.27, java sdk 1.4.2
> Apparently tomcat 4.x complies with jsp spec 1.2, which as far as I can
> see includes the XML syntax used above. 
> 
> thanks,
> kind regards,
> Luke
>