Craig,
thank you for your immediate help. Trying it out, however, I found some
rather strange behavior of my code: the "perform" method of the Action
that returns the pdf file seems to be called a second time after the
the file has been sent. This seems to cause the browser to try to
display something very strange (because it complains about a missing
plug/in). I tried the file return code in isolation (in a simple
servlet without struts) and it worked just fine. Am I missing something
here?.
Here is the code that I am running:
public final class ViewAction extends Action{
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
System.out.println( "enter view::perform" );
String cmd = this.getCmd( request );
System.out.println( "cmd=" + cmd );
if( cmd == null ){
System.out.println( "exit view::perform (cmd==null)" );
return null;
}
if( cmd.equals( "Quelle" ) || cmd.equals( "Ziel" ) || cmd.equals(
"Dauer" )){
// do something ...
System.out.println( "exit view::perform (sort)" );
return new ActionForward( mapping.getInput() );
}
if( cmd.equals( "pdf" ) ){
// return pdf file ...
ServletOutputStream out = response.getOutputStream();
response.setContentType( "application/pdf" );
try{
this.returnFile(
"c:\\www\\public_html\\webapps\\odin-tracer\\tmp\\pdfoutput.pdf", out );
}
catch( FileNotFoundException e ){
e.printStackTrace();
}
catch( IOException e ){
e.printStackTrace();
}
System.out.println( "exit view::perform (pdf)" );
return null;
}
System.out.println( "exit view::perform (end)" );
return null;
}
}
Running this code gives the following output (with hitting the "submit"
button in the form only once):
enter view::perform
cmd=pdf
exit view::perform (pdf)
enter view::perform
cmd=null
exit view::perform
(cmd==null)
Any clue what is going on here?
Best Regards,
Jürgen
--
Dr. Jürgen Lind
iteratec GmbH Fon: +49 (0)89 614551-44
Inselkammerstrasse 4 Fax: +49 (0)89 614551-10
82008 Unterhaching Web: www.iteratec.de