Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Servlets
Proper technique for forwarding servlets
Darryl Failla
Ranch Hand
Posts: 129
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What is the proper technique for a controller
servlet
to forward to another servlet? For example, in servlet A:
if(x == y)
forward to servlet B
else
forward to servlet C
Darryl Failla
Sun Certified Java 2 Programmer
Thambi Rajah
Ranch Hand
Posts: 36
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The following code may be helpful to your question.
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { RequestDispatcher rd = null; int x=0; int y=1; if (x == y) { rd = getServletContext().getRequestDispatcher("/servlet/com.dispatcher.ServletB"); rd.forward(req,res); } else { rd = getServletContext().getRequestDispatcher("/servlet/com.dispatcher.ServletC"); rd.forward(req,res); } }
Good Luck,
Thambi
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Technique for shared servlet data
servlets: can we override service method ?if yes how and why?if no then why?
return back to same page
how to download doc file in jsp in weblogic
Struts 2 In Action : Redirect After Post
More...