GetServletContext().setAttribute  problems

I try to deploy the "testfile.war" in WebLogic 6.1
          I put it inside the C:\bea\wlserver6.1\config\mydomain\applications
          folder.
          But I got the following errors, after I restart the server
          Seems to be problems with a path or missing packages that I should
          import.
          Anyone got any diea?
          Compilation of
          'C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java'
          failed:
          C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:126:
          cannot
          resolve symbol probably occurred due to an error in
          /include/application_realpath.jsp line 2: if
          C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:127:
          cannot resolve
          symbol probably occurred due to an error in
          /include/application_realpath.jsp line 3:
          getServletContext().setAttribute("appRealPath",
          getServletContext().getRealPath("/"));
          C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:127:
          cannot resolve
          symbol probably occurred due to an error in
          /include/application_realpath.jsp line 3:
          getServletContext().setAttribute("appRealPath",
          getServletContext().getRealPath("/"));
          

I try to deploy the "testfile.war" in WebLogic 6.1
I put it inside the
C:\bea\wlserver6.1\config\mydomain\applications
folder.
But I got the following errors, after I restart the
server
Seems to be problems with a path or missing packages
that I should
import.
Anyone got any diea?Yep .. hope u get this because inside a jsp page to get the servlet context you have to first get the page context and from that u have to get the servlet context.,
C:\bea\wlserver6.1\config\mydomain\applications\testfil
\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servle
\_main\__testing_page.java:127:
cannot resolve
symbol probably occurred due to an error in
/include/application_realpath.jsp line 3:
getServletContext().setAttribute("appRealPath",
getServletContext().getRealPath("/"));
why do you use getServletContext() method , it is already an implicit variable in the jsp page as "application"
just use application.setAttribute()
application.getRealPath()
regards,
Arun.N

Similar Messages

  • GetServletContext().getAttribute problems

    I try to deploy the "testfile.war" in WebLogic 6.1
              I put it inside the C:\bea\wlserver6.1\config\mydomain\applications
              folder.
              But I got the following errors, after I restart the server
              Seems to be problems with a path or missing packages that I should
              import.
              Anyone got any diea?
              Compilation of
              'C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java'
              failed:
              C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:126:
              cannot
              resolve symbol probably occurred due to an error in
              /include/application_realpath.jsp line 2: if
              C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:127:
              cannot resolve
              symbol probably occurred due to an error in
              /include/application_realpath.jsp line 3:
              getServletContext().setAttribute("appRealPath",
              getServletContext().getRealPath("/"));
              C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:127:
              cannot resolve
              symbol probably occurred due to an error in
              /include/application_realpath.jsp line 3:
              getServletContext().setAttribute("appRealPath",
              getServletContext().getRealPath("/"));
              

    Richard,
              Since you are seeing muliptle definitions of sc, you should be able change the code to look like:
              <%
              sc.setAttribute("appRealPath",getServletConfig().getServletContext().getRealPath("/"));
              out.println(Kit.dispLkup(getServletConfig().getServletContext().getAttribute("appRealPath"),null));
              out.println(" The appRealPath is: " + getServletConfig().getServletContext().getRealPath("/"));
              %>
              Thanks,
              Simon
              Developer Relations Engineer
              BEA Support
              Richard wrote:
              > On Tue, 19 Mar 2002 11:23:57 -0700, Simon Nunn
              > <[email protected]> wrote:
              >
              > Simon,
              >
              > I did the following in my code:
              >
              > <%
              >
              > ServletContext sc = getServletConfig().getServletContext();
              > sc.setAttribute("appRealPath",sc.getRealPath("/"));
              > out.println(Kit.dispLkup(sc.getAttribute("appRealPath"),null));
              > out.println(" The appRealPath is: " + sc.getRealPath("/"));
              >
              > %>
              >
              > I have "ServletContext sc" defined in only one file.
              > After I restart the server, the Weblogic server would generate the
              > servlets automatically from my JSP files. The previous errors are now
              > gone, but now there are some new errors. The following errors occur
              > in those generate servlets.
              >
              >
              > C:\bea\wlserver6.1\config\mydomain\applications\.wlnotdelete\WEB-INF\_tmp_war_myserver_myserver_progress\jsp_servlet\_main\__todo_add_form.java:158:
              > sc is already defined in
              > _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
              > probably occurred due to an error in /include/application_realpath.jsp
              > line 3:
              > ServletContext sc = getServletConfig().getServletContext();
              >
              > C:\bea\wlserver6.1\config\mydomain\applications\.wlnotdelete\WEB-INF\_tmp_war_myserver_myserver_progress\jsp_servlet\_main\__todo_add_form.java:208:
              > sc is already defined in
              > _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
              > probably occurred due to an error in /include/application_realpath.jsp
              > line 3:
              > ServletContext sc = getServletConfig().getServletContext();
              >
              > Thanks
              >
              > >Richard,
              > >
              > > I believe that your code should look like:
              > > <%
              > >
              > >ServletContext sc = getServletConfig().getServletContext();
              > >sc.setAttribute("appRealPath",sc.getRealPath("/"));
              > >out.println(" The appRealPath is: " + sc.getRealPath("/"));
              > >%>
              > >
              > >I tested this and it works for me under 6.1 sp2.
              > >
              > >Thanks,
              > > Simon
              > > Developer Relations Engineer
              > > BEA Support
              > >
              > >Richard wrote:
              > >
              > >> I try to deploy the "testfile.war" in WebLogic 6.1
              > >> I put it inside the C:\bea\wlserver6.1\config\mydomain\applications
              > >> folder.
              > >>
              > >> But I got the following errors, after I restart the server
              > >> Seems to be problems with a path or missing packages that I should
              > >> import.
              > >> Anyone got any diea?
              > >>
              > >> Compilation of
              > >> 'C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java'
              > >> failed:
              > >>
              > >>
              > >> C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:126:
              > >> cannot
              > >> resolve symbol probably occurred due to an error in
              > >> /include/application_realpath.jsp line 2: if
              > >>
              > >> C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:127:
              > >> cannot resolve
              > >> symbol probably occurred due to an error in
              > >> /include/application_realpath.jsp line 3:
              > >> getServletContext().setAttribute("appRealPath",
              > >> getServletContext().getRealPath("/"));
              > >>
              > >> C:\bea\wlserver6.1\config\mydomain\applications\testfile\WEB-INF\_tmp_war_myserver_myserver_testfile\jsp_servlet\_main\__testing_page.java:127:
              > >> cannot resolve
              > >> symbol probably occurred due to an error in
              > >> /include/application_realpath.jsp line 3:
              > >> getServletContext().setAttribute("appRealPath",
              > >> getServletContext().getRealPath("/"));
              

  • Problem with forward using RequestDispatcher

    Dear All
    Below is my code, which trying to use the RequestDispatcher.forward to go from a Servlet to a .jsp page.
    and use
    getServletContext().setAttribute("SvBio",vBio);
    to set an attribute
    It compiles finely but stuck at the forward request to the jsp page and through an exception which is given below.
    BUT on removing this statement
    getServletContext().setAttribute("SvBio",vBio);
    from my doget method , it works and forwrds to the next page
    please help me identifying the problem
    Thanks
    NAV
    ////Part of CODE////////////////
    Vector vBio;
    public void init()
    // vector vBio initialize in init()
    public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
    getServletContext().setAttribute("SvBio",vBio);
    if(param1 == bio)
    gotoPage("/jsp_pages/bio_gp.jsp", request, response);
    private void gotoPage(String address, HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
    if(dispatcher !=null)
    dispatcher.forward(request, response);
    ///exception//////////////////
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at nav.gotoPage(nav.java:363)
         at nav.doGet(nav.java:319)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
         at java.lang.Thread.run(Thread.java:595)
    root cause
    java.lang.NullPointerException
         at org.apache.jsp.bio_gp_jsp._jspService(bio_gp_jsp.java:59)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at nav.gotoPage(nav.java:363)
         at nav.doGet(nav.java:319)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
         at java.lang.Thread.run(Thread.java:595)
    Apache Tomcat/4.1.29-LE-jdk14

    Thanks evnafets
    I find out null pointer assignment in jsp page where forward request was heading.
    There is one more question, if you help me a better understanding the issue
    I have a HTML page invokes the servlet by passing value of parameter, Servlet do some procesing and forward to JSP page depending on the incoming parameter,
    Can JSP page invoke the same servlet by passing some other parameter?
    I tried doing this, but it returns an empty page and didnt went back to servlet.
    HTML Page ---->Servlet--------> JSP page ---------> Servlet
    I think Forward method shift the control from the Servlet to JSP page and now its the responsibility of the jsp page to deliver the response to the client.
    Am i getting the empty page on invoking the servlet from the JSP page because I have not deliver the response to the client?
    ///the code of the JSP page is as fallows///
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>NAVTITLE</title>
    </head>
    <body link="#0000FF" vlink="#0000FF" alink="#0000FF">
    <td height="340" width="977">
    <p align="center"><font size="8" color="#001000"><b>biomolecular group           page</b></font></p>
    <%@page import="java.util.Vector"%>          
    <% Vector vBiopt = (Vector)getServletContext().getAttribute("SvBio");     
    out.println("\nThe size of vBio is ::"+vBiopt.size());
    int n = vBiopt.size();
    %>
    <p>This is the dynamic page generated for the biomolecular group</p>
    <%
    for(int k=0;k<n;k++)
    String href1 ="http://localhost:8080/nav/nav2?param2=";
    String item = (String)vBiopt.elementAt(k);
    out.println("<p><a href= \"" + href1 + k + "\">" + item + "</a></p>");
    %>
    </body>
    </html>

  • Application scope problem in a JSP

    Hi,
    I try to store an object with the following code :
    getServletContext().setAttribute("application", app);
    Later I want to access this object from a JSP with :
    <jsp:useBean id="application" scope="application" class="de.skillworks.SWApp"/>
    that dosn't work !? I can not debug my application because the jsp is initializing my app object new. When I try in my JSP :
    SWApp app = (SWApp)pageContext.getServletContext().getAttribute("application");
    it works fine. I get my object which I have store in my servlet.
    In a Tomcat environment my code is working just the Jdeveloper has a problem with it.
    null

    Andy -
    The web-to-go server has difficulty dealing with sessions. Testing in Tomcat is a good alternative, and this is resolved in Oracle9i JDeveloper.
    Hope this helps,
    Lynn

  • Problems with passing arguments to app

    Hi.
    I have a litle problem with passing arguments. I create a dynamic jnlp file using jsp. This is my code:
    <%
    response.setContentType("application/x-java-jnlp-file");
    String l = request.getParameter("login");
    String p = request.getParameter("pass");
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println("<jnlp spec=\"1.0+\" codebase=\"http://212.244.104.27:8080/PzP_INSTALL/\" href=\"pzp.jsp\">");
    out.println("<information>");
    out.println("<title>xxx</title>");
    out.println("<vendor>xxxx</vendor>");
    out.println("<homepage href=\"main.jsp\"/>");
    out.println("<description>text</description>");
    out.println("<offline-allowed/>");
    out.println("</information>");
    out.println("<security>");
    out.println("<all-permissions/>");
    out.println("</security>");
    out.println("<resources>");
    out.println("<j2se version=\"1.4+\"/>");
    out.println("<jar href=\"jars/pzp.jar\" main=\"true\" download=\"eager\"/>");
    out.println("<jar href=\"jars/config.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-beanutils.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-collections.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-digester.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-logging.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-validator.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/easclient.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/easj2ee.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/jakarta-oro-2.0.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/jbcl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/log4j-1.2.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/jdom.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/xercesImpl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<property name =\"javaws.login \"  " + "value=" + "\"" + l + "\"" + "/>");
    out.println("<property name =\"javaws.pass \"  " + "value=" + "\"" + p + "\"" + "/>");
    out.println("</resources>");
    out.println("<application-desc main-class=\"aaa.bbb.ccc.MyClass\"/>");
    out.println("</jnlp>");
    %>My problem is when i have the href tag filled, the arguments that i passed equlas null, when i remove the href everything is ok besides that the app doesnt show in application manager and doesnt create an icon on the desktop.
    out.println("<jnlp spec=\"1.0+\" codebase=\"http://62.89.104.27:8080/PzP_INSTALL/\" href=\"pzp.jsp\">");
    Any help would be appreciated.

    Hello again.
    Thanks for your replay but unfortunetly it doesnt work too :-(
    I've tried to use the out.println statemants in the servlet instead of using a jsp page but the error is the same. Please look at my code and tell me if you can what could be wrong.
    This is the error message:
    An error occurred while launching/running the application.
    Title: PZP
    Vendor: SPEED
    Category: Download Error
    Unable to load resource: http://212.89.104.27:8080/PzP_INSTALL/ServletPZP
    Servlet code.
    package pzp_install;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import pzp_install.LoginBean;
    import javax.swing.JOptionPane;
    public class ServletPZP extends HttpServlet {
      public void init(ServletConfig config) throws ServletException {
      super.init(config);
      config.getServletContext().setAttribute("ServletPZP", this);
      public void doPost(HttpServletRequest request, HttpServletResponse resp)
      throws IOException {
      PrintWriter out = resp.getWriter();
    // Get the value of the request parameter
      String login = request.getParameter("login");
      String pass = request.getParameter("pass");
    resp.setContentType("application/x-java-jnlp-file");
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println("<jnlp spec=\"1.0+\" codebase=\"http://212.89.104.27:8080/PzP_INSTALL/\" href=\"/servletpzp\">");
    out.println("<information>");
    out.println("<title>PZP</title>");
    out.println("<vendor>SPEED</vendor>");
    out.println("<homepage href=\"main.jsp\"/>");
    out.println("<description>Aplikacja wspomagajaca zarzadzanie zleceniami</description>");
    out.println("<offline-allowed/>");
    out.println("</information>");
    out.println("<security>");
    out.println("<all-permissions/>");
    out.println("</security>");
    out.println("<resources>");
    out.println("<j2se version=\"1.4+\"/>");
    out.println("<jar href=\"pzp.jar\" main=\"true\" download=\"eager\"/>");
    out.println("<jar href=\"config.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-beanutils.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-collections.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-digester.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-logging.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-validator.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"easclient.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"easj2ee.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jakarta-oro-2.0.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jbcl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"log4j-1.2.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jdom.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"xercesImpl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<property name =\"javaws.login \"  " + "value=" + "\"" + login + "\"" + "/>");
    out.println("<property name =\"javaws.pass \"  " + "value=" + "\"" + pass + "\"" + "/>");
    out.println("</resources>");
    out.println("<application-desc main-class=\"pl.speednet.pzp.PzP\"/>");
    out.println("</jnlp>");
      public void destroy() {
      super.destroy();
    This is the brief of code which starts the servlet
    <form action="http://212.89.104.27:8080/PzP_INSTALL/servletpzp" method="post">
      <input type="hide" name="login" value=<%=l%>>
      <input type="hide" name="pass" value=<%=p%>>
      <input type=submit value=Start PZP>
    </form>
    This is the web.xml file code.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <servlet>
        <servlet-name>ServletPZP</servlet-name>
        <servlet-class>pzp_install.ServletPZP</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>ServletPZP</servlet-name>
        <url-pattern>/servletpzp</url-pattern>
      </servlet-mapping>
      <mime-mapping>
        <extension>jar</extension>
        <mime-type>application/x-java-archive</mime-type>
      </mime-mapping>
      <mime-mapping>
        <extension>jnlp</extension>
        <mime-type>application/x-java-jnlp-file</mime-type>
      </mime-mapping>
    </web-app>

  • Problem with set/get attributes

    Hello,
    i'm trying to assign and object i've got to the ServletContext by :
    getServletContext().setAttribute("theairwaybill",theairwaybill);
    and i''ve checked and it's there.
    now, trying to get the object back in my jsp page by:
    theairwaybill = (Shipments.Awb)getServletContext().getAttribute("theairwaybill");
    and i know i've got the object by comparing both my local object's address and the one from the ServletContext() but the values of the variables are null and zeros from unknown reason...?
    what can be reason?
    10x ahead,
    netanel

    try to get the context object from config object then try
    sorry i dont have time to help out out... busy schedule bye

  • Setting up JNDI resources in web.xml only

    Hi,
    I'm using Tomca 4.0 LE and JDK 1.4.0_01.
    I've been using a database connection pool on my local machine by editing the server.xml file and web.xml. However, I need to move the webapp onto a web hosting compaines server (same tomcat and jdk version). I cannot edit the server.xml file, so I need to set up my JNDI resource in web.xml only.
    I have done this (in web.xml):
    <resource-ref>
          <res-ref-name>jdbc/ocb_clients</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
      </resource-ref> Now, before when I had this all set up in web.xml, I had a list of <ResourceParams> within the <context> element:
    <ResourceParams name="jdbc/ocb_clients">
        <parameter>
          <name>factory</name>
          <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <parameter>
         <name>username</name>
         <value>username_here</value>
        </parameter>
        <parameter>
         <name>password</name>
         <value>password_here</value>
        </parameter>          
        <parameter>
           <name>driverClassName</name>
           <value>org.gjt.mm.mysql.Driver</value>
        </parameter>       
        <parameter>
          <name>url</name>
          <value>jdbc:mysql://localhost:3306/ocb_clients</value>
        </parameter>
      </ResourceParams>These parameters are obviously needed for the datasource to work. How can I set these up just using web.xml?
    Also, this code is from a servlet that I have loading on tomcat startup. Will this still work with the new configuration?
    public void init() throws ServletException
         DataSource ds = null;       
         try
           //Set up the inital context
           Context ctx = new InitialContext();
           //Look up the database
           ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ocb_clients");
         catch(NamingException nameE)
           System.err.println("Error looking up database: " + nameE);
         //Add the datasource to the application scope
         getServletContext().setAttribute("ocbDatabase", ds);
      }Any help is greatly appricated,
    Thanks, Mel.

    I am Having exactly the same problem with tomcat 5.0. I have tried to do everything mention as solutions at different fourums but I failed.
    BTW I am using MySQL
    Thanks
    Dibakar

  • Best practice for property file

    I am trying one small code which uses values from property file.
    public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException
          InputStream inputStream = servletContext.getResourceAsStream(/WEB-INF/test.properties);
          PrintWriter out         = response.getWriter();
           Properties prop = new Properties();
           prop.load(inputStream);
           inputStream.close();
          String nameprop = prop.getProperty("name");
          out.println(nameprop);
       }I am getting the value from property file, It's perfectly ok as far as test code is concerned. Above will open the inputStream for each thread, which is not needed so i modified it and put in inside init() method. That is also working, i believe this will give me some better performance.
    But can i extend it further? I load property file at application level and all my servlets make use of it?
    What is normal practice to read property file to get good performance? I serached forum, i found some info there but could not figure out exactly how people are doing it.
    Thanks in advance,
    regards
    Manisha

    Thanks to all posters,
    As mentioned by duffymo, I tried some code which i tested on my m/c and working fine. But just want to confirm, what i understood and wrote is correct.
    I wrote 1st servlet to get the property file and store into servlet context, 2nd servlet is just to test it.
    1st Servlet:
    package common;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class TestPropertyfiles_1 extends HttpServlet
    public void init(ServletConfig config) throws ServletException
       super.init(config);
       try{
            String PF_PATH = "/WEB-INF/test.properties";
            Properties prop = new Properties();
                            InputStream inputStream = config.getServletContext().getResourceAsStream(PF_PATH);
           prop.load(inputStream);
           inputStream.close();
           getServletContext().setAttribute("pf", prop);
       }catch(Exception e){}
    public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException
            PrintWriter out         = response.getWriter();
            Properties tmpprop = (Properties) getServletContext().getAttribute("pf");
            String nameprop = tmpprop.getProperty("name");     
                out.println("name from property file" + nameprop);     
    }2nd servlet:
    package common;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class TestPropertyfiles_2 extends HttpServlet
         public void init(ServletConfig config) throws ServletException
            super.init(config);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException
            PrintWriter out         = response.getWriter();
            Properties tmpprop = (Properties) getServletContext().getAttribute("pf");
            String nameprop = tmpprop.getProperty("name");
                            out.println("name from property file - no 2" + nameprop);
    }This was initially giving problem if I access 2nd servlet first before accessing 1st servlet. I did some changes inside web.xml
    <servlet>
    <servlet-name>common.TestPropertyfiles_1</servlet-name>
    <servlet-class>common.TestPropertyfiles_1</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    And then all was ok.
    One thing came to my mind. I can have one common servlet just for all initialisation, this will not have any doGet/doPost.
    regards
    Manisha

  • Servlet creates data bean

    hi there,
    i need to get my servlet (dataBeanLoader) to create some class object, that creates a data bean.
    this bean needs to be used by other JSP(application scope)
    I have something like:
    MyBean mb = new MyBean()
    mb.setSomething(vrednost1);
    getServletConfig().getServletContext().setAttribute("myBean", mb); in init() of the servlet. but I get : java.lang.NullPointerException on
    getServletConfig().getServletContext().setAttribute("myBean", mb);
    I am not sure what to do.
    this dataBeanLoader needs to go to web.xml to be loaded everytime server is rebooted.
    let me know what I am doing wrong
    thanks
    nn

    Hey there
    thanks for you help,
    i found what the problem was.
    I call 2 different functions from init() that create bean without passing them ServletConfig object.
    That was the problem.
    thanks!

  • html:select and html:options simple question  - please help

    Hi Friends,
    I am having a problem, please help me .I want to run a query and display all the lastnames of all the users in my database.Here are my files:
    UserForm.java
    public class UserForm extends ActionForm{
         private name firstName;
         private name lastName;
         //all getter and setters
    viewuser.jsp
    <html:select property="lastName">
        <html:options collection="users" property="lastName" labelProperty="lastName" />
    </html:select>
    and my Java Utility class method
    public ArrayList getusers() throws Exception {
             ArrayList aList = new ArrayList();     
              Connection con = ConnectionUtil.getConnection();
              PreparedStatement stmt = null;
              try {
                   stmt = con.prepareStatement("select last_name from USERS);     
                   ResultSet rs = stmt.executeQuery();
                      if (rs.next()) {
                          aList.add(rs.getString(1));
                      }else {
                           return null;
                      rs.close();
                      return aList;
              } catch (SQLException e) {
                   e.printStackTrace();
                   throw new ServiceProcessingException(e.getMessage());
              } finally {
                   ConnectionUtil.closeStatement(stmt);
                   ConnectionUtil.closeConnection(con);
         }My problem is what i need to do in my Action class,so that it sets the "users" variable
    properly and i would be able to read that variable in my jsp and display the lastname
    of all the users.I am tryin this but failing badly:
    public class UserAction extends Action{
      ArrayList userssList = Utility_class_obj.getUsers();
      request.getSession().getServletContext().setAttribute("users", usersList);Please Please help,I would really appreciate your help.
    Thanks

    Thanks a lot friend...this time i made it work my style,next time i will use tha mehod.But I think I am not doing it the right way,please correct me:
    This is the method in my utility class where i run the query and I doubt I am not doing it right here:
    PreparedStatement stmt = null;
    ViewForm vForm = null;
    try {
    stmt = con.prepareStatement("SELECT LAST_NAME FROM   USERS_ADD");     \
    ResultSet rs = stmt.executeQuery();          
    while(rs.next()) {
           vForm = new ViewForm(rs.getString(1));          
          aList.add(vForm);          
       rs.close();
       return aList;          }
    }And I made this constructor in my viewForm class:
    public ViewForm(String lastName){          this.setLastName(lastName);     }I do this in my Action class then:
    ArrayList pList = csDAO.getUsers();  
         if(pList  != null){         
         request.getSession().getServletContext().setAttribute("plist", pList);      
    }And finally this in my jsp:
        <html:select property="lastName"> 
        <html: options collection="plist" property="lastName" labelProperty="lastName" /> And it works,but i don't think I can keep adding constructors to my form class like that,and moreoever if I want to search by first name ,there would be a conflict between 2 constructors,so can someone please tell me the right way to do this.
    Thanks
    Mick

  • Servlets 'n' Beans,  (table 2)

    Hi all,
    Got a problem!
    Am working on a servlet that uses a bean to store some important variables. I would then like have the servlet call a JSP page that has access to the bean and its vraibles, thus
    delivering content specific to the values of the bean.
    Been looking at examples of application scope beans, but they all tend to point setting a name and value using the methods as follows:
              Type1 value1 = (computeValueFromRequest("request");
                        getServletContext().setAttribute("key1", "value1");This to me seems like you are creating a bean on the fly and looks like it will complicate the servlet with many statements in order to set all the contents of your bean.
    This doesn't appeal to me as I have already created my bean class with all its accessor methods in order to get away from this.
    Hoping for some help,
    Thanks, thee olde wizard

    You are not limited to string values for the attributes. And you certainly don't want to keep attributes that change fast in the servlet context; what about using the session's attributes?
    SomeObject sob = new SomeObject();
    sob.setXyz(9);
    ... // bla bla bla
    request.getSession().setAttribute("someObject", sob);
    // forward to JSP now

  • Shared memory or session

    Hi all,
    my problem is , I need to store a file contents in the memory or a session, and this session or memory block can be accessed by all the other sessions (clients).
    is this applicable in java ? , I am on a dedicated tomcat env.

    public class ServletA extends HttpServlet
        public void doGet(....)
            List myList = new ArrayList();
            // Stores the List into application scope.
            getServletContext().setAttribute("MyKey", myList);
    public class ServletB extends HttpServlet
        public void doGet(....)
            // Retrieves the List from application scope.
            List list = (List)(getServletContext().getAttribute("MyKey"));
    }

  • How to keep an application level object running with SunIDM?

    We are working on intergrate a gmail project with SunIDM. We need an application level object running with SunIDM so it will maintain a token generated from Gmail side. In anther servlet project, I had this object saved in the attribute of the ServletContext, then other session level servlet could share this attribute anytime. Is there a way to store attribute in Servlet Context and have it shared by different user session in SunIDM? I have been reading documents and searched this forum, haven't find any topics related how to maintain an application level object live. Hopefully that I can get some hint here.
    Thank you so much.

    Paul, Thank you so much for the further explaination. I don't think it will work since the token generated from gmail will expire every 24 hours.
    We are using the gdata library published from by gmail people, and I create a new UserService object and have it run in the application level. The UserService object will generate a token and renew it every 24 hours behind the scene. Here is how I implement it in my Servlet project:
    //to have a UserService object running at the application level:
    public class GmailUserService extends HttpServlet {
    public void init(ServletConfig config) throws ServletException{
    super.init();
    userService = new UserService(myApplication);
    config.getServletContext().setAttribute("gmailUserService", userService);
    //to access this UserService object from other servlet in each user session:
    UserService userService = (UserService)servletContext.getAttribute("gmailUserService");
    Gmail will trigger an error if we create a new UserService object for each user. They recommend to have all the user to share one UserService object. I am looking for similar approach in SunIDM.
    Thank you again, Paul, for trying to help.

  • Missing Session :(

    Hello Everybody,
    I have an issue with session in JSF application where am using a Servlet filter .
    When i code like this
    servletconfig.getServletContext().setAttribute ("profile", profileObject);
    Though object gets placed in session but later when i try to get it in my backing bean as below
    Profile objProfile =(Profile) request.getAttribute("profile");
    I donot get this object? Wondering why my session is lost.
    On the other hand if i use following piece of code it works perfect.
    ServletContext ctx = filterConfig.getServletContext();
         LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
         FacesContextFactory factory =(FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
         FacesContext context = factory.getFacesContext( (Object) ctx,(Object)objHttpServletRequest, (Object)objHttpServletResponse, lifecycle);
    context.getExternalContext().getSessionMap().put("profile", profileObject);
    Any reason why it is so? Am using RAD 6.0 and WAS6.0
    Thanx.

    Well...
    servletconfig.getServletContext().setAttribute ("profile", profileObject);
    You are putting that object in the ServletContext, not the HttpSession. And...
    Profile objProfile =(Profile) request.getAttribute("profile");
    Is trying to get the object out of the HttpRequest rather than the HttpSession.
    ServletContext, HttpSession, and HttpRequest are all different.

  • JDBC Connection to an external Database in NW2004s !

    Hello,
    using the J2EE Server in NW2004s i'm facing some troubles in an Servlet, wich should get the connection from the J2EE Server with an jndi lookup. The JDBC driver is deployed by our hosting partner via the Visual Administrator.
    The next step was to create an datasource in the SAP NetWeaver Administrator ( Web Fronted ) and an alias to this datasource.
    The alias is "bpitrigger".
    Finally the servlet code :
    public void init() throws ServletException {
              // TODO Auto-generated method stub
              log.info("Init Methode startet.");
              log.info("Get DB Connection with JNDI Lookup.");
              DataSource ds = null;
              String contextName = "jdbc/bpitrigger";
              log.debug("Suche in Context nach " + contextName);
              try{
                   Context cont = new InitialContext();
                   ds = (DataSource) cont.lookup(contextName);
                   Connection con = ds.getConnection();
                   this.stmt = con.createStatement();
                   this.getServletContext().setAttribute("statement", stmt);
              catch(Exception e){
                   log.error("Error on DataSource. " + e.getMessage());
              log.debug("Datasource : " + ds.toString());
    The logging of the servlet is telling me, that no object with the name bpitrigger could be found.
    My question is : how can i verify in the j2ee server, that the deployed jdbc driver is working and can be referenced over the jndi context with the alias ?

    JNDI Lookup ist working.

Maybe you are looking for