File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Can Jsp be  converted into String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Can Jsp be  converted into String" Watch "Can Jsp be  converted into String" New topic
Author

Can Jsp be converted into String

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Hi
I m trying to store the contents of JSP in a stringbuffer
Using BufferedReader with FileReader object as a parameter to its constructor
but BufferedReader donot read the character at column position 1
say
<?xml version="1.0" ?>
- <Schema>
- <Task Id="2">
<Td>2</Td>
<TName>1</TName>
<TBRule>1</TBRule>
<TType>1</TType>
<TDur>1</TDur>
<Txcor>456</Txcor>
<Tycor>252</Tycor>
<TImage>Task.bmp</TImage>
</Task>
</Schema>
It skips the character "<" in the beginning of tag
<?xml version="1.0" ?>
and same character from tag </Schema>
So is there any other way of retrieving the whole xml in a stringbuffer ?


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 3901
The problem might be this. readln() strips of the line returns so you have to tack them on. Either with "\n" or better
System.getProperty("line.separator")

I should have used a StringBuffer here but oh well

[This message has been edited by Randall Twede (edited March 09, 2001).]


I never took notes in college. That's how I got a 4.0 the first 2 years, and a 3.5 the second two years.
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Sorry for asking again
but are u considering line as a String and if yes
have u given it some default value???
Originally posted by Randall Twede:
[B]The problem might be this. readln() strips of the line returns so you have to tack them on. Either with "\n" or better
System.getProperty("line.separator")

I should have used a StringBuffer here but oh well
[This message has been edited by Randall Twede (edited March 09, 2001).][/B]

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 3901
Gaurov,
I use the above code to read a .txt file into my servlet as a string. In my servlet I create an object of the class the code is in and call that method to read a file as a string. You could just incorporate the code in your servlet.
Like I said I'm not sure if that is your problem. I just know you have to add linefeeds like in my example.
[This message has been edited by Randall Twede (edited March 10, 2001).]
 
 
subject: Can Jsp be converted into String
 
Threads others viewed
ClassCastException in struts - urgent! :(
Classic tags. browser is not responding.
jsp, xml,Servlets
reponseXML empty Ajax/Struts
JSP and XML
developer file tools