hai, i am not able to get the instance of the servlet by giving its name in context.getServlet(name); i know this method is not capable of loading the required servlet into the memory. but this method returns null even if i send a request to the required servlet externally in the browser as well as sending a request programatically(ie. somehow making it available in the memory).so please help me get out of this problem. yours balraj
hai sardha, thanks for your reply.you have said the alternative for req.sendRedirect().so using requestdispatcher i can touch the doGet and doPost methods but my intension is to touch all methods of the servlet instance that is presently available in the memory. awaiting your reply yours balraj
The reason this call was deprecated is that there is no guarantee that there will be one instance of the named servlet in memory. The servlet container is free to have no instances (if the other servlet has not yet been "init" ed or has already been "destroy"ed) or more than one instance, or even to run the named servlet in another virtual machine completely. Attempting to access an instance of a servlet in this way is very dangerous and unpredictable, so modern servlet containers are defined to always return null from getServlet(). Can you give us more idea of what you need to achieve? Maybe we can help you find a solution which doesn't involve access to another loaded servlet.
hi, actually i am not trying to get the servlet instance without loading it.i did by externally loading it thro' adminstration tool of javawebserver as well as by putting the request thro' browser.in both cases i falied to get the instance.it returned only null. so again i tried it by loading programatically thro' socket connection and this time also i falied to get the instance. so combining my experience with your explanation,what i understood is that it is always returning null even if it is available in the memory. well.the actual intention is that i am creating a servletbean and loads its jar file in the JWS.now my intension is to change its properties from an outside servlet.please help me to work out this one. yours balraj
Joined: Jan 07, 1999
This is what the servlet context is for. As your servlet is initialized, you can put your bean into the ServletContext using getServletContext().setAttribute(name, value); Other servlets will then be able to retrieve the object using getServletContext().getAttribute(name);
Joined: Nov 22, 2008
thanks for your answer and will try this one and i hope now it will work. thanks a lot, yours balraj