Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To break the execution in a JSP page?  RSS feed

 
Kumar Navin
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Friends,
If anyone knows how to break the execution in the middle of the execution of a JSP page. Suppose my JSP page has 100 lines of code and I want to execute the first 30 lines and stop the execution. This is to be used only for debugging purpose. Like in ASP you have response.end, do we have anything in JSP also??
Thanks.
-Navin.
 
pradeep jaladi
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Stopping the execution in middile of the 100 lines . Suppose at the line 50 . Then check whether any condition satifies then simply forward it to the error page.
String name = session.getParameter(name);
if ( name == "XYZ")
{
// move to the Error Page
}
else

contiune ur page processing

I think this will help u to sort out ur problem.
Ok if not keep a mail to me at pradeepjaldi@sify.com

I can send u example.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
throw new NullPointerException("Oops!");

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36396
453
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another alternative is to comment out the rest.

Be careful if you try Jeroen's approach of throwing an exception. Depending on when the stream was last flushed and the exception configuration, you may not get the end of the output you do want.
 
Sumitro Palit
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about creating an empty custom tag called myBreak.
Just implement the Tag interface, make doStartTag return SKIP_BODY and doEndTag return SKIP_PAGE. (You can do the same by extending TagSupport and implementing doEndTag to return SKIP_PAGE).

This will will give you a clean way of stopping execution at any point of your JSP and has the advantage of being reusable. You might want to output some message to indicate that you are using this tag to break, so that if you leave it in by mistake you'll be able to spot it quickly.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!