aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP document (complete post) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP document (complete post)" Watch "JSP document (complete post)" New topic
Author

JSP document (complete post)

Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
Hi all,

I have create a simple JSP document as following

<html xmlns:jsp="http://java.sun.com/JSP/Page">
<head>
<title>Hello World</title>
</head>
<body>
<jsp:scriptlet> out.println("Hello World !"); </jsp:scriptlet>
</body>
</html>

and I am surprised to see an XML document in my browser. as you can see the container is adding the line <?xml version="1.0"... ?> at the beginning of the document (during translation phase). That is why I am seeing the content of my XML file as below:

<?xml version="1.0" encoding="UTF-8" ?>
<html>
- <head>
<title>Hello World</title>
</head>
<body>Hello World !</body>
</html>

I expected the code HTML to be interpreted, but it is not. MY question is there a mean to make my HTML code interpreted ? If not this means we cannot make anything we can with conventionnal JSP syntax.

Finally I

Thanks for who will have the patience to answer my question.
Tiggy
Sivasundaram Umapathy
Ranch Hand

Joined: Aug 10, 2002
Posts: 360
The xml declaration can be avoided in 2 ways so that your document is considered as HTML.

1. By making use of <jsp:root> in your JSP document. In this case, the xml declaration is not added by default.

2. Using the <jsputput> action with the omit-xml-declaration set to "true" or "yes"

i.e <jsputput omit-xml-declaration="true">


Siva
Co-Author - SCMAD Exam Guide - ISBN:9780070077881
Author - Java certification success, Part 4: SCEA
Sivasundaram Umapathy
Ranch Hand

Joined: Aug 10, 2002
Posts: 360
tiggy tiggy, Can you please change your display name according to Javaranch naming policy ?
Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
Thanks a lot

your response is very clear and brief, exactely what I expected

Tiggy
Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
I changed my name as required

Have a nice day
Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
Just a note. I have tested the code

<html xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp utput omit-xml-declaration="true"/>

<head>
<title>A JSP document</title>
</head>
<body>
<jsp:scriptlet> out.println("Hello World !"); </jsp:scriptlet>
</body>
</html>

I still received this text in my browser but as forseen without the <?xml... declaration

<html>
- <head>
<title>A JSP document</title>
</head>
<body>Hello World !</body>
</html>

I checked on the class java generated and I see why it is like that. In fact I have the following line:

response.setContentType("text/xml;charset=UTF-8");

I guess this is because IE do not handle UTF8 yet.

Of course if we add the following directive this makes the things running right:

<jsp irective.page contentType="text/html"/>

That was just for your information.

Adri
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP document (complete post)