GeeCON Prague 2014*
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
Author

How to pass initParameter to the servlet

Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
Hello,
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.
Thanx,
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.

Bosun


Bosun (SCJP, SCWCD)
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: http://www.javaranch.com/ubb/Forum7/HTML/000638.html
 
Consider Paul's rocket mass heater.
 
subject: How to pass initParameter to the servlet