• 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

how to save jsp report to the text file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have generated a JSP Report and I need to save the report into the text file format. I mean the JSP Report output should be painted on text file.
Your suggestion kindly aprreciated.

Regards,
Prakash
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,

I am also facing the same problem.pls ,if u find any solution for saving jsp page as text file then forward ur suggesstions and sample coding..

Thank you

Regards
Babu
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume that you would have a Servlet that backs up this JSP page. You could make the servlet print out a text file (or a csv file) with the data you want.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use the follwing code in your jsp.

<%
response.setContentType("text/plain");
response.setHeader("content-disposition","attachment; filename=temp.txt");
%>
 
yoga babu
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,
thanks for your time.actually i inserted ur coding in my program but file is not having any data.pls check my previous coding,and tell me where i have do modification and where i have to insert ur codings..pls help me.


<%
FileOutputStream outfile;
PrintStream p,p1;
outfile= new FileOutputStream("d:\\temp\\error1.txt");
outfile= new FileOutputStream(filename);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:pro","pro","pro");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from CSG where Module='7613-slot6' ");
p = new PrintStream(outfile);
p.println(" Module DateTime Allocated Memory Available Memory

OsStaic Memory");

while(rs.next())
{

String date=rs.getString(1);
String time=rs.getString(2);
String availablememory=rs.getString(3);
String allocatedmemory=rs.getString(4);
String osstatic=rs.getString(5);

p.println(" "+date+" "+time+" "+availablememory+"

"+allocatedmemory+" "+osstatic+" ");
}
%>

thanks a lot

Regards
Babu
 
Ranch Hand
Posts: 53
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

You should tell us why your code is not working and what error message you receive when you execute the JSP page. But as a first guess I think you should close your Streams by calling p.close()and outfile.close(). And I would delete the PrintStream p1 variable because it is never used.

Sincerly,
Ernie
 
yoga babu
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In My coding i m not getting any error.but i want to save my data according to user wish.But in my program i mention particular name for the file and location.
For that i add this coomand ,then
response.setContentType("text/plain");
response.setHeader("Content-Disposition", "attachment;filename=File1.txt");
i m getting plain text file,its not having any data in the corresponding selected location.what i have to do...pls guide me..


Thanks a lot

With Regards
Babu
 
There's a city wid manhunt for this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic