• 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

creating a text file from JSP

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have read the psoting concerning my issue but it seems nothing is exactly what i need. i need to create a text file based on the html page seen on the user's screen (the HTML page is generated by the JSP page, i mean it is originally a JSP page but it appears as a HTML page on the user's screen right?) and save it in the user's computer can it be done and how?

please help........

thanks
 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once the jsp page is rendered to the user, it is like any other web page. You can save the page through the browser. Or is it that you want to do capture the rendered page at the server side and then save it in the user's computer?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot write anything to the client system without the user taking action.

You can instruct the user to use View Source to obtain the HTML, or you can use techniques to capture the HTML on the server and provide a link to the user. But you cannot write to the client file system.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this topic.
 
evan theon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Once the jsp page is rendered to the user, it is like any other web page. You >can save the page through the browser. Or is it that you want to do capture >the rendered page at the server side and then save it in the user's computer?

i am not sure which one is suitable for me, i just want to create a text file from a jsp page, just like creating an excel file from a jsp page using response.setContentType and response.setHeader, can it be done the same way? i've tried to change

response.setContentType("application/vnd.ms-excel");

response.setHeader("Content-disposition","attachment;filename=file1.sxc");


into

response.setContentType("application/vnd.ms-word");
response.setHeader("Content-disposition","attachment;filename=file1.txt");

but i have a text file contained with the HTML source code, what i want is that the text file contains the HTML page that seen on user's screen not the HTML source code

what should i do?
 
evan theon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please help.....i would be very thankful.....
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by evan theon:
>Once the jsp page is rendered to the user, it is like any other web page. You >can save the page through the browser. Or is it that you want to do capture >the rendered page at the server side and then save it in the user's computer?

i am not sure which one is suitable for me, i just want to create a text file from a jsp page, just like creating an excel file from a jsp page using response.setContentType and response.setHeader, can it be done the same way? i've tried to change

response.setContentType("application/vnd.ms-excel");

response.setHeader("Content-disposition","attachment;filename=file1.sxc");


into

response.setContentType("application/vnd.ms-word");
response.setHeader("Content-disposition","attachment;filename=file1.txt");

but i have a text file contained with the HTML source code, what i want is that the text file contains the HTML page that seen on user's screen not the HTML source code

what should i do?



It looks like there is a slight misunderstanding here.
Setting the content type to "application/vnd.ms-excel", does not cause the JSP to "create" an Excel page. The page you're creating is exactly the same as it would be with any other content type. All you're doing is sending a header to the browser which suggests that the browser open this file with the application associated with that content type (in this case Excel).
You don't see the HTML markup because Excel is capable of interpreting HTML and presenting it as a spread sheet.

If you instruct the browser to open a document in Word and tell word that this is a text file (text meaning no markup), it's going to render it exactly the way it is written (markup and all).

I think Word can also interpret HTML. I know you can convert a Word doc to HTML from within word (hideous html but that's another topic). Try leaving the content type as you have it but set the file extension to ".html" in the disposition tag.
It might work.

If not, look into Jakarta POI and see if you can create a "REAL" Word document on the server and stream that down to the client.

The truth is, there is no spoon

Also:

please help.....i would be very thankful.....


Before adding another post to a thread that looks like this, you might want to read: Patience Is A Virtue to learn how you may actually be slowing down your answers.
[ September 10, 2005: Message edited by: Ben Souther ]
 
evan theon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm really sorry for being impatience but it is not my intention to do that....but it is because the deadline is hunting me down...
once again i'm really sorry, but usually this forum gives answer even quicker than i thought, so i assumed you guys were busy so i give some kinda reminder but once again i'm really sorry
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More importantly, did you understand what I meant when I said that JSP doesn't actually "create" a native format MS-Office file?
 
evan theon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now i understand that JSP doesn't actually "create" a native format MS-Office file...
OK i give up... maybe i should try the Jakarta POI project that you mentioned earlier, but can you give me a brief explanation of what it is, how to used it, how to combine it with JSP? or maybe a good reference would be great.... where should i strat learning about Jakarta POI?

thank you very much for your help....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope,
but I'm sure their documentation could.
http://jakarta.apache.org/poi/
 
reply
    Bookmark Topic Watch Topic
  • New Topic