File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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:
I agree. Here's the link:
subject: How to pass initParameter to the servlet
It's not a secret anymore!