• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can Jsp be converted into String

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

 
Randall Twede
Ranch Hand
Posts: 4489
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4489
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic