Discussions

Web tier: servlets, JSP, Web frameworks: servlet/web.xml configuration question

  1. servlet/web.xml configuration question (2 messages)

    I'm new to Object-Oriented Programming so please bear with me as I stumble along and ask my questions. I have a servlet located at /WEB-INF/classes/inventory/AssetMove.java. I keep getting "AssetMove.java:26: cannot resolve symbol
    symbol : variable application
    location: class inventory.AssetMove
                           String PROPERTIES_FILE = application.getInitParameter("webfile.properties");" This application.getInitParameter is located in a try block. My web.xml file has an entry of "<context-param>
                   <param-name>webfile.properties</param-name>
                   <param-value>/export/home/tomcat/resources/inventory.properties</param-value>
           </context-param>." Why can't the compiler resolve this line? Thank you in advance.
  2. servlet/web.xml configuration question[ Go to top ]

    there is no variable named "application" in your class. that's why the compiler is complaining. there is no built-in reference to the servlet context from within a servlet, so if you want access to a context parameter, you'll need to do something like:

    String param = getServletContext().getInitParameter("webfile.properties");
  3. The application object is available only in JSPs. You probably mixed code from a JSP example........