• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EPractice Lab quiz 1 about passing config values from servlet A to servlet B

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You have implemented an Front Controller for your web application. The controller servlet needs to pass some config variables specific to CustomerManagerServlet. The config data must be passed, whenever CustomerManagerServlet called. The data may not be required for any other servlets.
In which object can the data that controller shares with CustomerManagerServlet be stored?

a. HttpSession
b. ServletConfig
c. ServletContext
d. HttpServletRequest
e. HttpServletResponse

Explanation:
Choice D is correct
Forward request will have the same HttpServletRequest object. We can store values in HttpServletRequest to communicate to other servlets.


I don't think I can forward the initial servlet config values from Controller to CMSerlvet.
My code example:





In the question, the config variables specific to CMServlet make me think those are the servlet's initial parameters.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



This is another example I can do to forward a request with attributes from a servlet to another.
But I don't see any example that the initial parameters of one servlet can be forward to another, like the question mentions.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2533
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand the question well, you will have to retrieve those config variables in the FrontController and store them (as attributes) on the HttpServletRequest before forwarding to the CustomerManagerServlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic