• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can Jsp be converted into String

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic