• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jweb+ question

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic