Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Foreman
Posts: 1898
12
  • 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 Foreman
Posts: 1898
12
  • 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.
 
Creator of Enthuware JWS+ V6
Posts: 3343
303
Android Eclipse IDE Chrome
  • 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.
 
Good night. Drive safely. Here's a tiny ad for the road:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic