• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mock exam questions...

 
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

This is taken from the mock exams:

Following is the code for doGet() method of TestServlet. Which of the given statements about it are correct?

public void doGet(HttpServletRequest req, HttpServletResponse res)
{
try{
RequestDispatcher rd = this.getServletContext().getRequestDispatcher("Login.jsp"); // 1
rd.forward(req, res); // 2
} catch(Exception e)
{ e.printStackTrace(); }
}

Select 2 correct options.
A.This will not compile.
B.This will compile but will not work as expected.
C.This code will work just fine.
D.It will compile but not work properly if //1 is replaced with: RequestDispatcher rd = req.getRequestDispatcher("Login.jsp");
E.It will compile and will work properly if //1 is replaced with: RequestDispatcher rd = req.getRequestDispatcher("Login.jsp");
ANS : C,E

My answer should be B, E. Am I wrong?
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find your answer to be right! B and E should be the right ones.
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mani,

But now I have doubt again:

8.Consider the web.xml snippet shown in the exhibit.
Now consider the code for a jsp file named unprotected.jsp:
<html>
<body>
<jsp:include page="/jsp/protected.jsp" />
</body>
</html>
Which of the following statements hold true when unprotected.jsp is requested by an unauthorized user?
<web-app>
...
<security-constraint>
<web-resource-collection>
<web-resource-name>test</web-resource-name>
<url-pattern>/jsp/protected.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
...
</web-app>
Select 1 correct option.
A.The user will be prompted to enter user name and password
B.An exception will be thrown
C.protected.jsp will be executed but it's output will not be included in the response
D.The call to include will be ignored
E.None of these
ANS : E

I think the answer should be B, because it is attempting to access unauthorized resource. Can someone explain this?
Thanks a lot.
 
reply
    Bookmark Topic Watch Topic
  • New Topic