IntelliJ Java IDE
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jweb+ question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "jweb+ question" Watch "jweb+ question" New topic
Author

jweb+ question

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Question ID :996245849311
Consider the code for two servlets of same webapp.
//In file LoginServlet.java
public class LoginServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
String userid = loginUser(req);
req.getSession().setAttribute("userid", userid);
}
}

//In file ReportServlet.java
public class ReportServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException
{
String userid = (String) req.getSession().getAttribute("userid");
if(userid != null) generateReport(req, res);
}
}
Assuming that loginUser() and generateReport() are valid methods and have no problems, which of the following statements about these servlets are true?
ReportServlet.java wont compile
generateReport will never be executed
generateReport will be executed if post req is s ent to LoginServlet before ReportServlet
share-session property must be true to get userid attribuet
None of the above
I think there is error in doXXX method declaration..so I thought it will be None of the above but the answer is 3..what do u think???
 
jQuery in Action, 2nd edition
 
subject: jweb+ question
 
developer file tools