Hello all,
a ques from j2eecertificate:-
1.public class ParamServlet extends HttpServlet {
2.protected void doGet(HttpServletRequest req, HttpServletResponse resp)
3.throws ServletException, IOException {
4.// insert code here
5.}
6.
Consider the following
servlet code. Which code can be used at line 4 to obtain a JavaBean called "account" that is stored in the application scope?
1. application.getAttribute("account");
2. getServletContext().getAttribute("account");
3. req.getSession().getServletContext().getAttribute("account");
4. servletContext.getAttribute("account");
5. request.getAttribute("account");
The ans is 2,3
How can 3 be the ans??how can we get a ServletContext from session??ther is no method defined in HttpSession to get a servlet Context from it??
My answers were 1 and 2.
Where am i wrong?Please help..
thanks,
mallika