You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcus Biel <Ma...@bmw.de> on 2003/01/16 10:28:36 UTC
Action without forward ?
Hi, I am using Struts 1.02 and got the following Problem:
I need to create a JSP where u can select to create a pdf or excel file.
The problem is, I didn't programm the Action to create the file, a
colleague did.
So I need some way to call his Servlet. I tried to map directly to it,
that did not work. So I wrote an Action that called a method to create
this pdf / excel file,
depending on the parameters given.
The problem is, that after this method there is no forward anymore, as
the control is given to the servlet
to create the file, and thats it. But the
public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
needs some forward.
For the moment I wrote "return null" but imho thats no prober solution.
Maybe you got an idea.
thanks,
marcus
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Kris Schneider <kr...@dotech.com>.
Sure:
<security-constraint>
<web-resource-collection>
<web-resource-name>Private</web-resource-name>
<url-pattern>/pdf/*</url-pattern>
</web-resource-collection>
<auth-constraint></auth-constraint>
</security-constraint>
The empty <auth-constraint> element causes all client requests for the collected
resources to be denied (it's still legal to perform forwards or includes, however).
Quoting Nicolas De Loof <ni...@cgey.com>:
>
>
> > Can't you just have the action that "fronts" the PDF servlet return a
> forward
> > that represents the path to that servlet?
> >
> > web.xml:
> >
> > <servlet-mapping>
> > <servlet-name>pdfServlet</servlet-name>
> > <url-pattern>/pdf</url-pattern>
> > <servlet-mapping>
> >
> > You could also include a <security-constraint> element to ensure that
> clients
> > can't make direct requests to the PDF servlet.
> >
>
> That was what I was thinking about, but I thought it would allow user to
> get
> direct request to pdf-servlet. I never used <security-constraint> (nobody's
> perfect ;-)), could you give us an example please ?
>
> Nico.
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Nicolas De Loof <ni...@cgey.com>.
> Can't you just have the action that "fronts" the PDF servlet return a
forward
> that represents the path to that servlet?
>
> web.xml:
>
> <servlet-mapping>
> <servlet-name>pdfServlet</servlet-name>
> <url-pattern>/pdf</url-pattern>
> <servlet-mapping>
>
> You could also include a <security-constraint> element to ensure that
clients
> can't make direct requests to the PDF servlet.
>
That was what I was thinking about, but I thought it would allow user to get
direct request to pdf-servlet. I never used <security-constraint> (nobody's
perfect ;-)), could you give us an example please ?
Nico.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Kris Schneider <kr...@dotech.com>.
Can't you just have the action that "fronts" the PDF servlet return a forward
that represents the path to that servlet?
web.xml:
<servlet-mapping>
<servlet-name>pdfServlet</servlet-name>
<url-pattern>/pdf</url-pattern>
<servlet-mapping>
You could also include a <security-constraint> element to ensure that clients
can't make direct requests to the PDF servlet.
struts-config.xml:
<global-forwards>
<forward name="pdfServlet" path="/pdf"/>
</global-forwards>
Quoting Marcus Biel <Ma...@bmw.de>:
> Because then I wouldnt have a request processor.
>
> The rest of the application is written in struts and uses the request
> processor to
> check wether the user is logged in or not.
>
> If not, he gets forwarded to the login page instead of creating a pdf.
>
> marcus
>
> nicolas.deloof@cgey.com schrieb:
> >
> > > > I never set content-length when generating response (PDF or not).
> > Perhaps
> > > > you have a mistake in length calculation and browser waits for EOF ?
> Try
> > > > without.
> > >
> > > Nope. I know it works as it works without Struts.
> > >
> >
> > So, why don't you just add a mapping in web.xml for your PDF-maker servlet
> ?
> >
> > Nico.
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Marcus Biel <Ma...@bmw.de>.
Because then I wouldnt have a request processor.
The rest of the application is written in struts and uses the request
processor to
check wether the user is logged in or not.
If not, he gets forwarded to the login page instead of creating a pdf.
marcus
nicolas.deloof@cgey.com schrieb:
>
> > > I never set content-length when generating response (PDF or not).
> Perhaps
> > > you have a mistake in length calculation and browser waits for EOF ? Try
> > > without.
> >
> > Nope. I know it works as it works without Struts.
> >
>
> So, why don't you just add a mapping in web.xml for your PDF-maker servlet ?
>
> Nico.
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Nicolas De Loof <ni...@cgey.com>.
> > I never set content-length when generating response (PDF or not).
Perhaps
> > you have a mistake in length calculation and browser waits for EOF ? Try
> > without.
>
> Nope. I know it works as it works without Struts.
>
So, why don't you just add a mapping in web.xml for your PDF-maker servlet ?
Nico.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Marcus Biel <Ma...@bmw.de>.
> I never set content-length when generating response (PDF or not). Perhaps
> you have a mistake in length calculation and browser waits for EOF ? Try
> without.
Nope. I know it works as it works without Struts.
nicolas.deloof@cgey.com schrieb:
>
> > It writes the binary value(pdf) into the response.getOutputStream,
> > with content-Type "application/pdf" und with content-length set.
> > But in the browser nothing can be seen, even though the pdf that gets
> > created correctly,
> > and the browser is loading the pdf-plugin.
> >
> >
> > Any ideas ?
> >
> > marcus
> >
>
> I never set content-length when generating response (PDF or not). Perhaps
> you have a mistake in length calculation and browser waits for EOF ? Try
> without.
>
> Nico.
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Nicolas De Loof <ni...@cgey.com>.
> It writes the binary value(pdf) into the response.getOutputStream,
> with content-Type "application/pdf" und with content-length set.
> But in the browser nothing can be seen, even though the pdf that gets
> created correctly,
> and the browser is loading the pdf-plugin.
>
>
> Any ideas ?
>
> marcus
>
I never set content-length when generating response (PDF or not). Perhaps
you have a mistake in length calculation and browser waits for EOF ? Try
without.
Nico.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Marcus Biel <Ma...@bmw.de>.
> I don't understand why you cannot directly use the PDF-generator servlet, by
> adding a dedicated mapping in your web.xml.
It needs to go through the request processor, to check if the user is
logged in
or not.
> perform() method in any action MAY return an ActionForward, but CAN return
> null if it has build the response for the client browser. This is commonly
> used for PDF or Excel generation, where they're is no need for a JSP.
It writes the binary value(pdf) into the response.getOutputStream,
with content-Type "application/pdf" und with content-length set.
But in the browser nothing can be seen, even though the pdf that gets
created correctly,
and the browser is loading the pdf-plugin.
Any ideas ?
marcus
nicolas.deloof@cgey.com schrieb:
>
> perform() method in any action MAY return an ActionForward, but CAN return
> null if it has build the response for the client browser. This is commonly
> used for PDF or Excel generation, where they're is no need for a JSP.
>
> I don't understand why you cannot directly use the PDF-generator servlet, by
> adding a dedicated mapping in your web.xml.
>
> Nico.
>
> > Hi, I am using Struts 1.02 and got the following Problem:
> > I need to create a JSP where u can select to create a pdf or excel file.
> >
> > The problem is, I didn't programm the Action to create the file, a
> > colleague did.
> > So I need some way to call his Servlet. I tried to map directly to it,
> > that did not work. So I wrote an Action that called a method to create
> > this pdf / excel file,
> > depending on the parameters given.
> >
> > The problem is, that after this method there is no forward anymore, as
> > the control is given to the servlet
> > to create the file, and thats it. But the
> > public ActionForward perform(
> > ActionMapping mapping,
> > ActionForm form,
> > HttpServletRequest request,
> > HttpServletResponse response)
> > {
> >
> > needs some forward.
> > For the moment I wrote "return null" but imho thats no prober solution.
> >
> > Maybe you got an idea.
> >
> >
> > thanks,
> >
> > marcus
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action without forward ?
Posted by Nicolas De Loof <ni...@cgey.com>.
perform() method in any action MAY return an ActionForward, but CAN return
null if it has build the response for the client browser. This is commonly
used for PDF or Excel generation, where they're is no need for a JSP.
I don't understand why you cannot directly use the PDF-generator servlet, by
adding a dedicated mapping in your web.xml.
Nico.
> Hi, I am using Struts 1.02 and got the following Problem:
> I need to create a JSP where u can select to create a pdf or excel file.
>
> The problem is, I didn't programm the Action to create the file, a
> colleague did.
> So I need some way to call his Servlet. I tried to map directly to it,
> that did not work. So I wrote an Action that called a method to create
> this pdf / excel file,
> depending on the parameters given.
>
> The problem is, that after this method there is no forward anymore, as
> the control is given to the servlet
> to create the file, and thats it. But the
> public ActionForward perform(
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> {
>
> needs some forward.
> For the moment I wrote "return null" but imho thats no prober solution.
>
> Maybe you got an idea.
>
>
> thanks,
>
> marcus
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>