Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 17309
11
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: 66144
143
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: 66144
143
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!