GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Converting JSP to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Converting JSP to XML" Watch "Converting JSP to XML" New topic
Author

Converting JSP to XML

Makrand Pare
Greenhorn

Joined: Dec 07, 2005
Posts: 10
Hi,

Is there a way to convert jsp files to XML?

Thanks,
Makrand
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

What does it mean to convert a JSP file to XML? Whose XML? What schema or DTD?

Or are you asking if there's a way to convert a JSP written in "normal" syntax to its .jspx equivalent? If so, why?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Makrand Pare
Greenhorn

Joined: Dec 07, 2005
Posts: 10
I'm really sorry to be so vague while asking my question.

Actually we have an old application developed in jsp.

There is another application developed in JSF which renders pages at run time.
For this the layout of the page is stored in an XML file.

The problem is, the layout in the old jsp pages now needs to be written in xml so that the new application can parse that XML and render the page.

we have an xsd for the xml files which need to be generated.
For example if in the old jsp page if there was a text field

<input type ="text" name="startDate" value=""/>

the equivalent tab in XML should be like:

<Field label="Start Date (mm/dd/yyyy)" name="startDate" position="3" type="inputText" value="" />

Definitely looking at each JSP and constructing XML by hand will be one option. But I was thinking is there a way of generating the XML automatically based on the JSP.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

This is a lot less about JSP than it is about XML and XML tools, so I've moved this off to the XML forum.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Is this something like your application would have the views in the form of XML and at runtime it would parse the XML's and render the required HTML chunk to the browser?

Well , if the jsp's that you are talking about are written by following a fixed standards then this might be possible , but if those are like jsp's written without any fixed standard as to just make it work then this might not be possible without manual intervention.

A tool for this would definately be a win , but I do not know whether such a tool could be make which would convert your jsps to XML without any human intervension.


Sounds like a big work for you!
[ September 10, 2007: Message edited by: Rahul Bhattacharjee ]

Rahul Bhattacharjee
LinkedIn - Blog
paritosh ranjan
Ranch Hand

Joined: Aug 24, 2007
Posts: 62
jsp files can use both normal jsp syntax and xml syntax
jsp files using normal jsp syntax are called jsp pages
and jsp files using xml syntax are called jsp documents

this is the example a jsp document counter_xml.jsp

<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
version="2.0">

<html><body>

<jsp:directive.page language="java" />

<jsp:declaration>
int count = 0;
</jsp:declaration>

<jsp:scriptlet>
count++;
</jsp:scriptlet>

<jsp:text>
Welcome! You are visitor number
</jsp:text>

<jsp:expression>
count
</jsp:expression>

</body></html>
</jsp:root>

Is this the thing you want??
a jsp page in xml format
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by paritosh ranjan:
Is this the thing you want??
a jsp page in xml format


I think the original poster has made it clear that he doesn't mean it.

;)
 
GeeCON Prague 2014
 
subject: Converting JSP to XML