Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing JSP in XML.  RSS feed

 
Rajul King
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was just wondering if there is any advantage to write JSP with XML syntax. Is it a editor friendly way of writing the JSP. Normal JSP editor such as Dreamweaver recognizes the conventional syntax very well. Do we need to use xml editor to write JSP.
I am sure there is some advantage towards writing JSP in XML because sun has included it in its specifications.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajul
I'm not sure what mean by writing JSPs with XML syntax. If you just mean making the JSP follow the XML syntax rules to make it well-formed then the most obvious advantage would be that your JSP could be processed by any XML processing application. I'm sure there are others that someone else here knows....
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean you want to use taglibs instead of scriptlets? That's advantageous when using things like dreamweaver for certain.
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So... when you write a JSP in normal JSP syntax (a JSP Page) is processed by an app server -- it's first translated into XML (the XML view), then into a Java Servlet, and finally compiled into a .class
The JSP Spec also gives the writer the option of writing their JSP page in XML syntax (a JSP Document). It too is then processed into an XML view, then into a Servlet and compiled into a .class
The advantages the spec lists for writing JSP Documents are (Servlet 2.3 spec section 5.1):
  • JSP documents can be passed directly to teh JSP container; this will become more important as more and more content is authored as XML.
  • The XML view of a JSP page can be used for validating the JSP page against some description of the set of valid pages
  • JSP documents can be manipulated by XML-aware tools.
  • A JSP document can be generated from a textual representation by applying an XML transformation, like XSLT.
  • A JSP document can be generated automatically, say by serializing some object.
  • You're bored.


  • ok.... so the last one isn't really in the spec...
    Also, check this thread for more info regarding JSP Documents and XML View.
    [ May 06, 2002: Message edited by: Jessica Sant ]
     
    Adam Hardy
    Ranch Hand
    Posts: 567
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Jessica,
    your point about using xslt to generate these JSP docs - sounds good but under what circumstances would you want to generate JSPs like that? (face showing lack of imagination)
     
    Jessica Sant
    Sheriff
    Posts: 4313
    Android IntelliJ IDE Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Adam Hardy:
    Hi Jessica,
    your point about using xslt to generate these JSP docs - sounds good but under what circumstances would you want to generate JSPs like that? (face showing lack of imagination)

    Well -- all those reasons came right out of the JSP specification -- so I can't take credit for them. BUT (lets see how well my imagination works this early in the morning) -- I could see someone using an xslt generation to create a JSP doc in an MVC architecture.
    You generate a single XML doc for a particular page, and then create different XSLT transformations dependent on the type of device that is connecting to the site (Mobile phone, PDA, Treo, IE, Netscape etc) and generate an individual JSP Document for each device.
    .... think that's all I've got in me for the morning Sound plausible?
     
    Rajul King
    Ranch Hand
    Posts: 47
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks a lot guys. It has been really very informative discussion.
    Jessica,
    Can you store all the building blocks of a jsp in the database and write a servlet to generate a jsp. when jsp goes to the browser, it converts it to the html page.
    regards,
     
    Jessica Sant
    Sheriff
    Posts: 4313
    Android IntelliJ IDE Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Rajul King:
    Jessica,
    Can you store all the building blocks of a jsp in the database and write a servlet to generate a jsp. when jsp goes to the browser, it converts it to the html page.

    I think it can be done -- it would require a lot of processing though... and I can't quite think of the advantage of doing that.... I think the XSLT transformation would be a better choice in most cases.
    [ May 09, 2002: Message edited by: Jessica Sant ]
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!