ServletContext « API « JSP-Servlet Q&A





1. ServletContext.getRequestDispatcher() vs ServletRequest.getRequestDispatcher()    stackoverflow.com

why

getRequestDispatcher(String path) of the ServletRequest interface cannot extend outside the current servlet context
where as
getRequestDispatcher(String path) of the ServletContext can use the ...

2. single method in getRequestDispatcher() in ServletRequest and ServletContext interfaces    stackoverflow.com

HI I like to know there is a single method called getRequestDispatcher() in ServletRequest and ServletContext interfaces. What is the difference?

3. Simple Servlet Question on ServletConfig instantiation    stackoverflow.com

Apparently the following is generating a loop(the GenericServlet class is calling the subclass's init())

public void init() throws ServletException {

  ServletConfig c = this.getServletConfig();
  super.init(c);

}
I'm probably just doing this ...

4. When does the ServletContext return a null RequestDispatcher?    stackoverflow.com

The api for ServletContext#getRequestDispatcher() says:

This method returns null if the ServletContext cannot return a RequestDispatcher.
and
Returns: a RequestDispatcher object that acts as a wrapper ...

5. JPEG file in WEB-INF returned as null by ServletContext#getResource()    stackoverflow.com

Good day! I am trying to output a JPG file contained in the web application to the user using the following code:

public class JpegOutput extends HttpServlet {

    protected void doGet(HttpServletRequest ...

6. ServletContextListener threads    stackoverflow.com

I'm currently having an issue with stopping a background thread in a webachive. I currently tie it in the war's deployment, and destroy it when the archive is un-deployed. The threads ...

7. Unterminated String Literal from getServletContext().getRealPath("/") in JSP    stackoverflow.com

This is an error that came up after I got a previous question here answered. Essentially I'm trying to bring the absPath of the folder with me so I can ...

8. Possible to Store a HashMap in the ServletContext?    stackoverflow.com

Is it possible to store a HashMap into the ServletContext in Java? When I go to get the attribute back it's a String...is there a way to cast it back ...

9. ServletContext attribute is null    stackoverflow.com

The attribute repository returns null.

public class BaseServlet extends HttpServlet {
    protected MyPersistentManager getPersistentManager(){
        return (MyPersistentManager) getServletContext().getAttribute("repository");
    }
//...
}
I am ...





10. Why is default constructor required for ServletContextAttributeListener?    stackoverflow.com

I created a class that implemented ServletContextAttributeListener without the default constructor and the container complained: SEVERE: Error configuring application listener of ..... java.lang.InstantiationException: ... So I created a default constructor in addition to parameterized ...

11. Store a collection in a ServletContext attribute?    stackoverflow.com

I'm using Servlets and I'm trying to .setAttribute an ArrayList. There are no compile-time errors, but when I run it it says that I can't cast a boolean to an ArrayList. ...

12. How can I print a servlet context attribute in EL?    stackoverflow.com

Is there a way I can get a attribute set in ServletContext in EL so that it ends up as a JavaScript variable? I am setting it as

context.setAttribute("testing.port", "9000");
I tried retrieving ...

14. difference between pagecontext and servletcontext    coderanch.com

Kesava, You've posted lots of questions to different forums. They are basic questions and you should be able to find out the answers for yourself by reading a Java book, searching through the archives of Java Ranch, or using Google. People here at Java Ranch enjoy answering questions, but we're not here to do your homework for you! If you have ...

15. Diffenrence between application and servletConfig - servletcontext    coderanch.com

Hello, I want to clarify the difference between using application objects [getattribute - setattribute] and the servletconfig - servletcontext objects. Please note that in my web application i create an init class called from the web.xml this class implement the servletcontextListener like the following code : ======================= public class Jcls_Init implements ServletContextListener { public void contextInitialized(ServletContextEvent sce) { sce.getServletContext().setAttribute("config","1"); } } ...

16. ServletContext vs. PageContext    coderanch.com





17. ServletContext and ServletConfig    coderanch.com

18. PageContext and servletContext    coderanch.com

20. ServletContext and RequestDispatcher?    coderanch.com

27. Attribute in ServletContext    coderanch.com

28. ServletContext and ServletConfig    coderanch.com

29. ServletContext and Attributes    coderanch.com

30. ServletConfig and ServletContext    coderanch.com

34. servletContext, servletConfig    coderanch.com

35. ServletContext's getContext() method    coderanch.com

36. about ServletContext and ServletConfig    coderanch.com

38. ServletConfig vs ServletContext    coderanch.com

39. servletContext& ServletConfig    coderanch.com

40. servletContext Vs servletConfig    coderanch.com

41. ServletConfig and ServletContext    coderanch.com

43. What is the difference between ServletContext and ServletConfig    coderanch.com

generally it's a belief that there is one servletcontext per application. but in reality this is the case when your application is running on one jvm. if your application is running on more than one jvm's than you have more than one servletcontext objects for your application (one servlet context object per jvm). but your servlet config object is always one ...

44. servletcontext-attribute    coderanch.com

45. servletcontext and servletconfig    coderanch.com

47. getContext method in ServletContext    coderanch.com

51. ServletContext Vs ServletConfig    coderanch.com

52. difference between the getContextPath of ServletRequest and ServletContext    coderanch.com

Thank you Bauke for the prompt reply. Can the values returned by the HttpServletRequest#getContextPath() and ServletContext#getContextPath() be different in any case? Generally, we give the context path in the application.xml(In case of JBoss and Websphere).Lets say for a Test.war, we give the context path as /Test in the application.xml. Now a call to ServletContext#getContextPath() made by a Servlet in Test.war, would ...

53. How to get ther servlet name from the Httprequest / servletContext    coderanch.com

Thanks for your reply. I have a requirement , to create a new request in the server side , based on the original request. So before making a URL connection. I need to check if the server name and port is same as the original request then I need to check the if the servlet name is available in the local ...

54. RequestDispatcher in servletcontext    coderanch.com

55. About ServletContext and ServletConfig    coderanch.com

56. ServletContext, its attribute to be shared for all over the Servlet?    coderanch.com

public void setDBContext() { // main initiated location for db.xml // to be shared for all servlets String location = "/WEB-INF"; String newLocation = getServletContext().getRealPath(location); getServletContext().setAttribute("dbxml-location", newLocation); // to obtain it use below code //String n = getServletContext().getAttribute("dbxml-location").toString(); } // always important to obtain the db location! public String getDBContext() { String path = getServletContext().getAttribute("dbxml-location").toString(); return path; }