my dog learned polymorphism*
The moose likes Servlets and the fly likes How to pass initParameter to the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to pass initParameter to the servlet" Watch "How to pass initParameter to the servlet" New topic

How to pass initParameter to the servlet

Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
I would like to pass some init parameters to the servlet, such that I can later retrieve it through the
ServletContext context =getServletContext();
String paraRetrieved=context.getInitParameter("SOMENAME");
My probelem is how to initialise/send the Parameters?
Also I am getting a strange probelem when I write:
context.setAttribute("Name",new String("Milan"));
stating that method() setAttribute(String, String) not found!
I am using JSDK2.0.
Please guide me.
Milan Doshi
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You have to use some kind of external mechanism such as a file or database. The specifics on doing this could vary depending on the webserver you are using.


So much trouble in the world -- Bob Marley
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

check the post i just made here:
It is sorta covered in the JavaRanch Style Guide.
subject: How to pass initParameter to the servlet
Similar Threads
Message Driven Bean sending/receiving messages from two places
Keyword xsl:sort may not be used here.
Probelem with MDB l(on weblogic 7.0) listening to MQ (Start-up class issue )
Passing parameter to a popup window in JSF
How Can a servlet automatically send a response without a request ?