This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Inserting a return command into a jsp  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Is there anyway to pass a return statement back to a jsp?

(Reason why I ask is because sometimes my calling jsp will call a bean or servlet that will need to do response.sendRedirect() and do not want the calling jsp to continue processing...instead I want the calling jsp to just immediately redirect to avoid response already committed exceptions)

For instance,



To get the same effect as this at runtime:



Edit: Just to clarify a little bit. The reason why I do not want to handle the if/then return statement in the calling jsp is because I do not want others to have to write the if/then return logic into their calling jsps should they want to implement my bean/servlet.

Thanks!
[ December 15, 2005: Message edited by: David Miranda ]
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>Is there anyway to pass a return statement back to a jsp?
No.
You can only "return" down one level in the call stack.
I suppose you could throw an exception to have it drop down multiple levels, but using exceptions to control program flow is bad karma.

You could possibly pass the data via a request attribute.
ie


Does that help?
 
Marshal
Posts: 67256
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could move such processing out of the JSPs altogether and make any forwarding and redirection decisions in a serlvet controller prior to even getting close to a JSP.
 
David Miranda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your input, Stefan and Bear!
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!