RE: jsp output to file

2003-11-06 Thread Greg Hess
To achive this I generaly use a utility method as defined below, note
the path argument will contain a full url including the session Id key
as the jsp is generaly relying on session data to build the output for
example(http://localhost/myapp/someAction.do;jsessionid=thesessionid).
The return can then be saved to file.

public static String executeHTTPRequest(String path)
{
String htmlContent = null;
ByteArrayOutputStream bout = new
ByteArrayOutputStream();
try
{
URL jspPage = new URL(path);
InputStream is = jspPage.openStream();
BufferedInputStream bin = new
BufferedInputStream(is,1024);
int data;
while((data = bin.read())0)
{
bout.write(data);
}
bin.close();
is.close();
htmlContent = new
String(bout.toByteArray()).trim();
}
catch(Exception e)
{
if(m_log.isErrorEnabled())
m_log.error(ToolBox ERROR:
executeHTTPRequest(path)path= + path + e);
}
return htmlContent;
}   

HTH,

Greg


 -Original Message-
 From: Jack Bakker [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, November 05, 2003 11:17 PM
 To: [EMAIL PROTECTED]
 Subject: jsp output to file
 
 I have a multi page wizard which ultimately produces 10 output pages
which
 show data entered into the form(s). The user then reviews the output
 pages,
 can modify input data, and then can click a final submit button when
 satisfied with their entries. So far so good. At this final
submission, I
 want to render the same 10 output pages but this time save them as
html
 files on the server.
 
 i.e., how can I, from one action, call 10 other actions and instead of
 returning output to the browser, save as a server-side html files.
 
  -- jack
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: jsp output to file

2003-11-06 Thread Jack Bakker
Thanks, I'll give this a try.

 -- jack

 -Original Message-
 From: Greg Hess [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 06, 2003 9:47 AM
 To: 'Struts Users Mailing List'
 Subject: RE: jsp output to file


 To achive this I generaly use a utility method as defined
 below, note the path argument will contain a full url
 including the session Id key as the jsp is generaly relying
 on session data to build the output for
 example(http://localhost/myapp/someAction.do;jsessionid=thesessionid).
 The return can then be saved to file.

   public static String executeHTTPRequest(String path)
   {
   String htmlContent = null;
   ByteArrayOutputStream bout = new
 ByteArrayOutputStream();
   try
   {
   URL jspPage = new URL(path);
   InputStream is = jspPage.openStream();
   BufferedInputStream bin = new
 BufferedInputStream(is,1024);
   int data;
   while((data = bin.read())0)
   {
   bout.write(data);
   }
   bin.close();
   is.close();
   htmlContent = new
 String(bout.toByteArray()).trim();
   }
   catch(Exception e)
   {
   if(m_log.isErrorEnabled())
   m_log.error(ToolBox ERROR:
 executeHTTPRequest(path)path= + path + e);
   }
   return htmlContent;
   }

 HTH,

 Greg


  -Original Message-
  From: Jack Bakker [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, November 05, 2003 11:17 PM
  To: [EMAIL PROTECTED]
  Subject: jsp output to file
 
  I have a multi page wizard which ultimately produces 10 output pages
 which
  show data entered into the form(s). The user then reviews
 the output
  pages, can modify input data, and then can click a final
 submit button
  when satisfied with their entries. So far so good. At this final
 submission, I
  want to render the same 10 output pages but this time save them as
 html
  files on the server.
 
  i.e., how can I, from one action, call 10 other actions and
 instead of
  returning output to the browser, save as a server-side html files.
 
   -- jack
 
 
 
 
 
 
 
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]