• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp Document vs Jsp Page - clarification

 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need clarification on what the difference is between a Jsp Document and a Jsp Page.

Here is my confusion. On the Sun practice cert exam a question reads:

"Which two tags can be used to insert Java code to be executed by a JSP page?"

The answers are <% %> and <jsp:scriplet> </jsp:scriplet>

Then a later question states that <% int i=12; %> is not valid in a JSP Document, not JSP page.

Is there a difference between a JSP Document and JSP Page?

Thanks,

JerryB
 
David Jublot
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
i think you can find more information on JSP document in the chapter 13 of the J2EE 1.4 tutorial
(http://java.sun.com/j2ee/1.4/docs/tutorial/doc/)

Apparently, a JSP document has a more compliant-XML syntax than a standard JSP.

hope this will help you
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP pages accept both JSP scriptlets, and JSP standard action tags.
So both <% %> and <jsp:scriplet> </jsp:scriplet> are ok.

In a JSP Document(i.e. xml file), only valid XML is allowed. If you want to write a scriptlet, you'll have to use <jsp:scriplet>int i=12;<jsp:scriplet>
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but still a little confused.

Page 597 of Head First Servlets & JSP has a list of Normal JSP page syntax and JSP document syntax.

The Normal JSP page syntax does not list anything like <jsp:....

Is this an omission in the book?

Thank you both for taking the time to answer my questions.

Sincerely.

JerryB
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not an omission. Normal Jsp syntax does not include <jsp> standard actions. But there are useable in any JSP pages and JSP documents.

What they call "Normal JSP page syntax" is the <% %> way of wrinting things, and "JSP document syntax" is the xml way of writing things.

Don't get confused and just remember that :
1. In JSP pages, you can use normal syntax (<% %>) and xml syntax (<jsp:.../>)
2. In JSP documents, you can only use valid xml (<jsp:.../>, but not <% %> )
[ December 12, 2005: Message edited by: Satou kurinosuke ]
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Satou.

Sincerely,

JerryB
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Normal Jsp syntax does not include <jsp> standard actions


<jsp:text>Satou_kurinosuke</jsp:text>
This is NOT called an JSP standard action. Refer page: 138&167(JSP 2.0 Spec). They are termed as JSP Document Syntax
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the table of contents :
Part I - Standard Actions - JSP.5.15 <jsp:text>
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

From the table of contents :
Part I - Standard Actions - JSP.5.15 <jsp:text>


Agreed.


JSP 2.0 Spec: Page: 165:

JSP.5.17 Other Standard Actions
<jsp:scriptlet> / <jsp:expression> / <jsp eclaration>


I missed this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic