Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how do i stop the Servlet from executing code after a certain line

 
Robert Johnson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if (teams.equals("empty")){
teams = "full";
numOfTeams = 0;
url2 = "http://localhost:8080/createLeagueWithNoAppError.jsp?username=" + username;
response.sendRedirect(url2);
}

here the Servlet executes all the code after this if statment even if it goes in this if block. it redirects fine but it executes the code the if block. Is there any way i can get it to stop after the send.Redirect?
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the rest of the code in the "else" part of the "if".

Mark
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or, just use the return keyword.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or, just use the return keyword.


Depends if you were brought up in the era of structured programming or not.

I've been classically conditioned to use Mark's "else approach". After all, you couldn't put a return just anywhere in FORTRAN!
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Classically Conditioned" eh? Somebody ring a bell and let's see what he does!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL, no one ever did the meat dust thing with me, so no salivating at the bell. I may come out swinging though!

P.S. Does anyone remember the comic strip Pavlov? I used to think it was hilarious.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!