This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes forwarding to a servlet instead of a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "forwarding to a servlet instead of a jsp" Watch "forwarding to a servlet instead of a jsp" New topic
Author

forwarding to a servlet instead of a jsp

dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Hello,

I want to forward to a servlet instead of a jsp from my action class. In my action class i retrieve the pdf from database as byte[]and then i want to forward to a servlet which displays this pdf. I dont want to use ForwardAction because i dont want the database code in the servlet. How can i forward to a servlet instead of a jsp from my action class? What are the changes i need to make?
[ February 22, 2006: Message edited by: dnyan ginde ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
To forward to a Servlet, just create a local forward that specifies the URL of your servlet and then return that ActionForward from the execute() method in your Action class.

example:
web.xml


struts-config.xml


execute() method in MyAction class:

return mapping.findForward("success");
[ February 22, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Thanks a ton Merrill
 
 
subject: forwarding to a servlet instead of a jsp
 
Similar Threads
Enable/Disable Hyperlink (Multiple Submits)
HOw to avoid ActionForward
calling my servlet when jsf jsp submitted
how to call servlet from struct action class
In JSF there is no form action