Java Reference
In-Depth Information
iif ( request . isUserInRole ( "host" )) {
out . println ( "<html><head><title>Welcome back, " +
request . getUserPrincipal (). getName () + "</title><head>" );
out . println ( "<body bgcolor=\"white\">" );
String command = request . getParameter ( "command" );
iif ( command . equals ( "reset" )) {
// Synchronize what you need, no more, no less.
synchronized
synchronized ( application ) {
application . setAttribute ( WINNER , null
null );
}
session . setAttribute ( "buzzin.message" , "RESET" );
} else
else iif ( command . equals ( "show" )) {
String winner = null
null ;
synchronized
synchronized ( application ) {
winner = ( String ) application . getAttribute ( WINNER );
}
iif ( winner == null
null ) {
session . setAttribute ( "buzzin.message" ,
"<b>No winner yet!</b>" );
} else
else {
session . setAttribute ( "buzzin.message" ,
"<b>Winner is: </b>" + winner );
}
}
else
else {
session . setAttribute ( "buzzin.message" ,
"ERROR: Command " + command + " invalid." );
}
RequestDispatcher rd = application . getRequestDispatcher (
"/hosts/index.jsp" );
rd . forward ( request , response );
} else
else {
out . println ( "<html><head><title>Nice try, but... </title><head>" );
out . println ( "<body bgcolor=\"white\">" );
out . println (
"I'm sorry, Dave, but you know I can't allow you to do that." );
out . println ( "Even if you are " + request . getUserPrincipal ());
}
out . println ( "</body></html>" );
}
}
Search WWH ::




Custom Search