Tomcat /manager commends from Servlet

Hi all,
I asked a question regarding the excution of Tomcat /manager commands from a servlet and I got no replies... :(
Well, I never found a way to directly execute the /manager commands from the servlet (API) - but I did (eventually) get it working via URLConnection. Now, I've decided to release my (simple) code here so that it may help others!
This code searches for a context and then checks if it is running, if it is found not to be running it will attempt to start it. (tested and found to work under Tomcat 5.0.28).
  String
    protocol  = "http",
    host      = "localhost",
    usr       = "usr",
    pwd       = "pwd",
    context   = "/myapp";
  int port = 80;
  URL list = new URL(protocol,host,port,"/manager/list");
  URLConnection c = (URLConnection)list.openConnection();
  String encs = new sun.misc.BASE64Encoder().encode((usr+":"+pwd).getBytes());
  c.setDoInput(true);
  c.setRequestProperty("Authorization", "Basic " + encs);
  c.connect();
  BufferedReader buf = new BufferedReader(new InputStreamReader(c.getInputStream()));
  String line;
  while ( (line = buf.readLine()) != null )
     * Search for the /workpackages context
    if ( line.startsWith(context+":") )
       * Found the context
       * Now make sure that it's running
      if ( line.indexOf("running") > 0 )
         * Context /workpackages found to be running!
          System.out.println("Context ["+context+"] - Running!");
      else
         * Context found NOT to be running!
         * Try and start the context!
        buf.close();
        System.out.println("Context ["+context+"] - Attempting to start context...");
        URL start = new URL(protocol,host,port,"/manager/start?path="+context);
        c = (URLConnection)start.openConnection();
        c.setDoInput(true);
        c.setRequestProperty("Authorization", "Basic " + encs);
        c.connect();
        buf = new BufferedReader(new InputStreamReader(c.getInputStream()));
        while ( (line = buf.readLine()) != null ) System.out.println(line);
      break;
notes:
The buffer reading after both commands seems to be required! I don't know why... But I found that without them, the manager commands seem to be ignored!?!? odd!
Well, I hope this helps someone...

thanx
but when i am Deploying directory or WAR file located on server
where is this XML Configuration file,
so that i can fill in the text box-XML Configuration file URL
and secondly in tomcat 5.5.4
there is no context path described in server.xml
so where is this in 5.5.4

Similar Messages

  • NT Lan Manager call from servlet

    Can someone please point me in the right direction for some documentation, or even an example, of how to access the NT Lan Manager user information from a Java Servlet?
    I am using iAS Java Edition.
    Best regards
    Christian Almgren

    You can use
    String s = response.encodeRedirectURL("http://www.sandeep.com/hello?sid=2222");
    response.sendRedirect(s);
    Or you could use the RequestDispatcher class
    RequestDispatcher rd = this.getServletConfig().getServletContext().getNamedDispatcher("myservlet")
    where myServlet is your registered name
    rd.forward(request,response);
    Hope this helps!!
    Sandeep
    null

  • Is it possible to set Tomcat Manager to lookup roles from DataSourceRealm?

    I know the Realm Configuration docs say that "Tomcat does not provide any built-in capabilities to maintain users and roles", but manager.xml contains the comment "Link to the user database we will get roles from", so that seems to imply that you can link to a different user database.
    I thought I could do this with JDBCRealm, but after using UserDatabaseRealm, I thought I might set up the dbase as a JNDI Datasource and authenticate and lookup roles via UserDatabaseRealm.
    After getting my database configured as a JNDI DataSource, and failing to authenticate against it via JNDIRealm, I realized that DataSourceRealm is a variation on JDBCRealm where you refer to the dbase via a JNDI DataSource. I have DataSourceRealm working, and I changed my Manager ResourceLink to point to the JNDI DataSource, but Tomcat Manager still can't lookup roles from anything other than the tomcat-users.xml demonstration file.
    The Admin Tool has screens where you can create users and roles, but this only seems to work with MemoryRealm and UserDatabaseRealm (xml files).
    Is this all just for demonstration?
    Is there no possibility of configuring TC Manager and Admintool to interface with an alternate user database (relational)?
    Shouldn't the docs clarify this by stating that you shouldn't bother trying to point the Manager ResourceLink at an alternate user database because it can't be done and the functionality is for demonstration of MemoryRealm and UserDatabaseRealm only?

    Its a 'Yes' or 'No' question.

  • How to connect to MS Access from servlet uploaded in TOMCAT server

    Hi,
    I want to access MS Access from servlet .I use TOMCAT server.I want to know what should i do.How to get drivers and how to set class path for them.
    Please help me in finding the solution
    thanks and Regards

    HI,
    try this
    <Code>
    response.setContentType(CONTENT_TYPE);
         PrintWriter out = response.getWriter();
         java.sql.DatabaseMetaData dm = null;
         java.sql.ResultSet rs = null;
         try
              Class.forName("sun,jdbc.odbc.JdbcOdbcDriver");
              Connection con = java.sql.DriverManager.getConnection("jdbc:odbc:dsnName","","");
              dm = con.getMetaData();
              out.println("<html>");
              out.println("<head><title>Servlet1</title></head>");
              out.println("<body bgcolor=\"lightblue\">");
              if(con!=null){
                   dm = con.getMetaData();
                   out.println("<B><br>Driver Information</B>");
                   out.println("\n\t<br><br>Driver Name: "+ dm.getDriverName());
                   out.println("\n\t<br>Driver Version: "+ dm.getDriverVersion ());
                   out.println("\n\t<br>Database Information ");
                   out.println("\n\t<br>Database Name: "+ dm.getDatabaseProductName());
                   out.println("\n\t<br>Database Version: "+ dm.getDatabaseProductVersion());
                   out.println("\n\t<br><br>Avalilable Catalogs ");
                   rs = dm.getCatalogs();
                   while(rs.next()){
                             out.println("<br>\tcatalog: "+ rs.getString(1));
                   out.println("\n\t<br><br>conURL =" + conURL);
                   out.println("\n\t<br><br>Title = Database");
                   rs.close();
                   rs = null;
                   con.close();
              }else {
                   out.println("Error: No active Connection");
         }catch(ClassNotFoundException e) {
              out.println("Coudn't laod the database driver: " + e.getMessage());
         } catch(SQLException e) {     
              out.println("SQLException caught: " + e.getMessage());
              try {
                   if (con != null)
                        con.close();
                   if (rs != null)
                        rs.close();
              catch (SQLException ignored) {}
              finally {
                   try {
                             if (con != null)
                                  con.close();
                             if (rs != null)
                                  rs.close();
                        catch (SQLException ignored) {}
    </Code>
    Sachin

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • Initialize managed bean from request parameters

    Hi:
    I thought this topic would be on the FAQ, but I couldn't find it. I am looking for a mean to initialize my managed bean from the query string. There must be something like:
    <h:form initializeBean=""true"" requestParameter=""id_author"" beanProperty=""#{author.id_author}"" action=""#{author.getFromDB}"" >
    </form>
    The url would be something like http://localhost:8080/protoJSF/showAuthor.jsf?id_author=5334
    And the getFromDB method would be something like
      Public void getFromDB()
         Statement stmt = cn.createStatement( ?SELECT * from author where id_author=? + getId_author() );
         ResultSet rs = stmt.executeQuery();
      }The only way I've found to perform something like this is to present a blank author form with a ''load data'' button: after pressing the button the user can see author's data and edit the data if she wants to. This two-step data screening is annoying, to say the least.
    There must be a better way.
    I beg for a pointer on how can I achieve the initializing of a managed bean with dynamic data.
    Regards
    Alberto Gaona

    You just have to read carefully the very fun 289 pages
    specification :-)Or, if 289 pages of JavaServer Faces is too much, you can get almost all of the same information from the JavaServer Pages 2.0 specification, or even the JSP Standard Tag Libraries specification :-).
    More seriously, the standard set of "magic" variable names that JavaServer Faces recognizes is the same as that reognized by the EL implementations in JSP and JSTL. Specifically:
    * applicationScope - Map of servlet context attributes
    * cooke - Map of cookies in this request
    * facesContext - The FacesContext instance for this request
    * header - Map of HTTP headers (max one value per header name)
    * headerValues - Map of HTTP headers (String array of values per header name)
    * initParam - Map of context initialization parameters for this webapp
    * param - Map of request parameters (max one value per parameter name)
    * paramMap - Map of request parameters (String array of values per parameter name)
    * requestScope - Map of request attributes for this request
    * sessionScope - Map of session attributes for this request
    * view - The UIViewRoot component at the base of the component tree for this view
    If you use a simple name other than the ones on this list, JavaServer Faces will search through request attributes, session attributes, and servlet context (application) attributes. If not found, it will then try to use the managed bean facility to create and configure an appropriate bean, and give it back to you.
    For extra fun, you can even create your own VariableResolver that can define additional "magic" variable names known to your application, and delegate to the standard VariableResolver for anything else.
    Craig McClanahan

  • Not able to access the native c code from servlet

    I want to call c function from servlet using JNI . I created the .so file and gave the library path . But when i try to load the library it says "Unsatisfied link error ". I am using tomcat on linux .. any more setting has to be done in order to call native code from servlets ?

    You need to post a little bit of code. What does your LoadLibrary() call look like?

  • Cannot get reference to a managed bean from another

    After reading one of BlausC article:
    http://balusc.blogspot.com/2006/06/communication-in-jsf.html#AccessingAnotherManagedBean
    I always get null when I try to get a reference to a session scoped managed bean from a current bean:
    Here is part of the faces context config file:
    <faces-config>
    <managed-bean>
      <managed-bean-name>approvalManagementBean</managed-bean-name>
      <managed-bean-class>com.waseel.waseele.presentation.approval.management.ApprovalManagementBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
      <property-name>configService</property-name>
      <property-class>com.waseel.waseele.business.config.ConfigService</property-class>
       <value>#{configService}</value>
      </managed-property>
      <managed-property>
       <property-name>approvalService</property-name>
       <property-class>com.waseel.waseele.business.approval.ApprovalService</property-class>
       <value>#{approvalService}</value>
      </managed-property>
      <managed-property>
       <property-name>claimManagementService</property-name>
       <property-class>com.waseel.waseele.business.claim.management.ClaimManagementService</property-class>
       <value>#{claimManagementService}</value>
      </managed-property>
      <managed-property>
       <property-name>codedValuesLoaderServices</property-name>
       <property-class>com.waseel.waseele.business.claim.extraction.loader.codedValuesLoader.CodedValuesLoaderServices</property-class>
       <value>#{codedValue}</value>
      </managed-property>
      <managed-property>
       <property-name>approvalSubmission</property-name>
       <property-class>com.waseel.waseele.business.approval.submission.ApprovalSubmission</property-class>
       <value>#{approvalSubmission}</value>
      </managed-property>
      <managed-property>
       <property-name>payerTpaRelationService</property-name>
       <property-class>com.waseel.waseele.business.payerTpaRelation.PayerTpaRelationService</property-class>
       <value>#{payerTpaRelationService}</value>
      </managed-property>
    <managed-property>
    <property-name>payerTpaFiller</property-name>
    <property-class>com.waseel.waseele.business.payerTpaRelation.PayerTpaFiller</property-class>
    <value>#{payerTpaFiller}</value>
    </managed-property>
    </managed-bean>and part of my code:
    public String displayApprovalInEditMode()throws Exception{          
              //This is cross-managed been access; I  need to get the current Approval in the approval management been
              ApprovalManagementBean appMangBean=(ApprovalManagementBean) FacesContext.getCurrentInstance()
                                                      .getExternalContext().getSessionMap().get("approvalManagementBean");What possible problems may be?
    Can any one tell when these session managed beans object get created? is it at start up? or when loading a JSF page that use a bean ?
    becasue this code work in places while not in another

    You must be doing something wrong. I cannot reproduce this problem with the following SSCCE on JSF 1.2_13 at Tomcat 6.0.20.
    Bean1package mypackage;
    public class Bean1 {
        private Bean2 bean2;
        public boolean isBean2Present() {
            return bean2 != null;
        public Bean2 getBean2() {
            return bean2;
        public void setBean2(Bean2 bean2) {
            this.bean2 = bean2;
    }Bean2package mypackage;
    public class Bean2 {
    }JSF<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <f:view>
        <html>
            <head>
                <title>Test</title>
            </head>
            <body>
                <h:outputText value="Is bean2 present? #{bean1.bean2Present ? 'yes' : 'no'}" />
           </body>
        </html>
    </f:view>faces-config<?xml version="1.0" encoding="UTF-8"?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
        version="1.2">
        <managed-bean>
            <managed-bean-name>bean1</managed-bean-name>
            <managed-bean-class>mypackage.Bean1</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
            <managed-property>
                <property-name>bean2</property-name>
                <value>#{bean2}</value>
            </managed-property>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>bean2</managed-bean-name>
            <managed-bean-class>mypackage.Bean2</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
    </faces-config>It prints 'yes'.

  • Tomcat Manager Portal in BlazeDS Turnkey Server

    Hi all,
    Im pretty new to blazeds, and liking what i have experienced thus far. Could anyone please tell me how to access the Tomcat Manager Portal within the BlazeDS Turnkey Server Installation.
    Like in know it runs on port 8400 by default. So running it then opening http://localhost:8400 gets me the blazeds turnkey home page with links to the sample apps.
    However I want to get to the Tomcat Portal to change file access permissions etc. And if i wanted to deploy apps from there etc.
    Is this possible?
    Please advise!
    Kind Regards
    Willem

    Follow the instructions here:
    http://blog.techstacks.com/2009/05/tomcat-management-setting-up-tomcat.html
    Basically just add a user and role to the $CATALINA_HOME/conf/tomcat-users.xml:
    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
      <role rolename="manager"/>
      <user username="tomcat" password="tomcat" roles="manager"/>
    </tomcat-users>
    Then use the URL: http://localhost:8400/manager/html to access the manager.

  • Restart Managed Server from Adminserver FAILED_NOT_RESTARTABLE

    Hi all,
    I've got problems restarting the managed server from the adminkonsole ('Control'-Tab) and from within wlst while connected to the adminserver 'start('mymanaged','Server','t3://localhost:80', block='true') connected with the adminserver.
    In the logfile of the administration occurs a nullPointerException:
    java.lang.NullPointerException
         at javax.mail.internet.MimeUtility.decodeText(MimeUtility.java:480)
         at weblogic.deploy.service.internal.transport.http.DeploymentServiceServlet.mimeDecode(DeploymentServiceServlet.java:788)
         at weblogic.deploy.service.internal.transport.http.DeploymentServiceServlet.authenticateRequest(DeploymentServiceServlet.java:523)
         at weblogic.deploy.service.internal.transport.http.DeploymentServiceServlet.doPost(DeploymentServiceServlet.java:194)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3214)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    The nodemanager-log shows an IOException:
    <02.02.2007 12:08:42> <Warning> <Exception while starting server 'sunetweb': java.io.IOException: Server failed to start up. See server output log for more details.>
    java.io.IOException: Server failed to start up. See server output log for more details.
         at weblogic.nodemanager.server.ServerManager.start(ServerManager.java:246)
         at weblogic.nodemanager.server.Handler.handleStart(Handler.java:463)
         at weblogic.nodemanager.server.Handler.handleCommand(Handler.java:115)
         at weblogic.nodemanager.server.Handler.run(Handler.java:66)
         at java.lang.Thread.run()V(Unknown Source)
    In the console, the serverstate of the managed server is:
    FAILED_NOT_RESTARTABLE
    But in config.xml both servers have set auto-restart:true.
    Starting from within wlst connected to Nodemanager instead works (nmStart("mymanaged", 'c:/win32app/bea/user_projects/domains/mydomain').
    Also the serverstart with a command file works.
    I want to restart the managed server from the console and from wlst connected to admin server.
    What is wrong ?
    Thanks, kind regards,
    Thomas

    Hi Jin,
    I use wlst now to do what I want.
    For a gentle restart of the managed server I connect to the Administration server and then run:
    #shutdown mymanaged gently
    shutdown(name='mymanaged',entityType='Server',ignoreSessions='true',timeOut=5, force='false')
    #start the sever again
    start('mymanaged','Server','t3://localhost:80', block='true')
    Still it is not possible to restart the managed server from console (stopping works).
    But wlst works for me.
    I won't follow this problem further.
    Thanks a lot.
    Kind regards,
    Thomas

  • Accessing Tomcat Manager Via URLConnection

    Hi,
    Does anyone know how to access Tomcat Manager using URLConnection? or Can it be done at all?
    I'm using URLConnection, javax.mail.authenticator, and javax.mail.PasswordAuthentication. It seems that I can get to the correct URL, but the servlet can't get pass thru the login dialog box(username ,password)
    for example if you're using Tomcat 5 and type http://localhost/manager/reload?path=/, this will prompt you a login dialog box and if you enter correct username and password with manager role, tomcat will reload the ROOT web application
    I want to get pass that login box, but my servlet doesn't seem to work.
    Here's my code so far:
    package reload;
    import javax.mail.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.net.*;
    public class Reload extends HttpServlet
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                                  throws ServletException, IOException
              URL url = new URL("http://localhost/manager/reload?path=/");
              URLConnection connection = url.openConnection();
               //----------------------------------Output Stream to supply username and password---
            javax.mail.Authenticator auth = new Auth();
              connection.setDoOutput(true);
              PrintWriter out = new PrintWriter(connection.getOutputStream());
              out.println(auth);   //this is supposed to supply the username and password to Tomcat
              out.close();
                //--------------------------------Input Stream to get content result-------------------
              BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
              String inputLine;
              while ((inputLine = in.readLine()) != null)
                   response.setContentType("text/html");
                   PrintWriter out1 = response.getWriter();
                   out1.println(inputLine);
              in.close();
           //-------------------sub class to store username and password-------------------------------
         private class Auth extends javax.mail.Authenticator
             public javax.mail.PasswordAuthentication getPasswordAuthentication()
                 return (new javax.mail.PasswordAuthentication("test","123"));
    }

    The manager application uses basic authentication. Therefore, you need to add a header to the request you make to the manager URL. Below is an example:
    HttpURLConnection httpconn = (HttpURLConnection)connection;
    String auth = strUsername + ":" + strPassword;
    httpconn.setRequestProperty("Authorization", "Basic " + Base64.encode(auth.getBytes()));
    The Base64 class is in the package org.apache.catalina.util, which is located in the file catalina-ant.jar. Here, I used it as a convenience.
    I also recommend re-writing your input/output loop to:
    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String inputLine;          
    PrintWriter out1 = response.getWriter();
    response.setContentType("text/html");               
    while ((inputLine = in.readLine()) != null)     {
         out1.println(inputLine);
    in.close();
    I hope this helps.

  • Send arraylist to swings from servlet

    Hi,
    I send string to jsp from swings using URL(pass as a query string)
    And then call servet from jsp(submit some values to this servlet from jsp)
    Now i want to send ArrayList to my swings ,
    How it is,
    i know call servlet from swings,retrive values from servlet to swings. This is two way communication,
    But now my requirement is one way, i didn't call servlet directly from swings, i call from jsp
    Help me,
    Thanks in advance

    Thanks for reply
    i write code in my swing as
    ArrayList pdetails;
    URL url=new URL(getCodeBase()+"sample.jsp");
                URLConnection con =url.openConnection();
                con.setDoInput(true);
                con.setDoOutput(true);
                con.setUseCaches(false);
                OutputStream outstream = con.getOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(outstream);
                oos.writeObject(pdetails);
                oos.flush();
                oos.close();
                AppletContext context=getAppletContext();
                context.showDocument(url,"_blank");my jsp code is
    <%@page import="java.io.*,java.util.*"%>
    <%
    ObjectInputStream inputFromApplet = null;
    ArrayList transmitContent =null;
    inputFromApplet = new ObjectInputStream(request.getInputStream());
    System.out.println(inputFromApplet);
    transmitContent = (ArrayList) inputFromApplet.readObject();
    out.println(transmitContent);
    %>
    but i got an exception like this21:28:50,078 WARN [[jsp]] Servlet.service() for servlet jsp threw exception
    java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream
    .java:2232)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputS
    tream.java:2698)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:750
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:268)
    at org.apache.jsp.sample_jsp._jspService(org.apache.jsp.sample_jsp:52)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
    .java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
    14)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
    lter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
    ipalValve.java:54)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
    yAssociationValve.java:174)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
    e.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
    a:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :868)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
    rocessConnection(Http11BaseProtocol.java:663)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
    int.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
    kerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)

  • Problem in Passing JTree object from Servlet pgm to browser

    Dear all:
    Can anybody help to resolve the problem - pass the JTree obejct from servlet (Tomcat) to IE 6.0. The JTree oject alway shows invalid charcter in IE. Following is my coding.
    import java.io.*;
    import java.awt.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.swing.*;
    import java.net.URL;
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.tree.*;
    //* Testing1 give it null
    public class SimpleServer extends HttpServlet
    DefaultMutableTreeNode top;
    DefaultMutableTreeNode EX01;
    DefaultMutableTreeNode EX02;
    DefaultMutableTreeNode QB01;
    DefaultMutableTreeNode QB02;
    DefaultMutableTreeNode N2BS;
    DefaultMutableTreeNode N2TS;
    //StringTokenizer st2, st1;
    String query;
    Connection con ;
    Statement statm;
    ResultSet res, backupRes;
    //RowSet res, backupRes;
    TreeSet treeset ;
    String [] tempArray;
    //ServletContext sc ;
    ObjectOutputStream out ;
    DefaultMutableTreeNode temp_node;
         public void doGet(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
    resp.setContentType("text/html");
    // resp.setContentType("application/octet-stream");
    System.out.println("create main node") ;
              out = new ObjectOutputStream(resp.getOutputStream());
              out.writeObject(this.set_NodeMain()); //no DB access,
         public void doPost(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
         try
         System.out.println("doPost " );
         doGet(req,resp);
              finally
         public DefaultMutableTreeNode set_NodeMain()
    top = new DefaultMutableTreeNode("Tandem");
    EX01 = new DefaultMutableTreeNode("EX01");
    EX02 = new DefaultMutableTreeNode("EX02");
    QB01 = new DefaultMutableTreeNode("QB01");
    QB02 = new DefaultMutableTreeNode("QB02");
    N2BS = new DefaultMutableTreeNode("N2BS");
    N2TS = new DefaultMutableTreeNode("N2TS");
    top.add(EX01);
    top.add(EX02);
    top.add(QB01);
    top.add(QB02);
    top.add(N2BS);
    top.add(N2TS);
    return top;
    }

    JMO - I hate seeing things like this in code:
    Just use whitespace to separate the methods.
    You can't just send a JTree to a browser. A browser has no idea how to render a Java object.
    Put that JTree inside an applet and make it part of a JSP. That'll work.
    MOD

  • Pass data from servlet to EJB3 and backward

    Hello All,
    The distributed application is being developed by the following scheme:
    J2EE Application Server (JBoss) - Servlet container (JBoss's contained Tomcat) - RIA client (Flex)
    Application server needs to handle client's requests and provide backward connectivity also.
    Servlets in this scheme are required by the BlazeDS library which is implemented as set of servlets handling HTTP requests from the clients.
    This forces us to:
    - invoke EJB from the servlet while handling client's requests.
    - invoke servlet from EJB for the sake of providing the client with urgent messages which need to be displayed immediately.
    The easiest ways to achieve that I am aware of are:
    - servlet invokes EJB via JNDI lookup (inefficient?)
    - EJB invokes servlet by passing HTTP request to web server (inefficient!)
    Is there standard and efficient ways to wire servlets(JSP) and EJB in either directions?
    Thanks,
    Alex.

    Hi Chicon,
    Thanks for advice. Probably I need to add few more words to make the question clearer.
    Chicon wrote:
    It is not the role of an EJB to fire a servlet. EJB's are only modules.
    In your case, the EJB invoked should pass the necessary data to the servlet. From the data it receives, the servlet has either to build and to send the HTML document(or other formats : pdf, txt, xml,...) or to fire the appropriate JSP to the client. The servlet may also call a more specific servlet to do the job, e.g. in a Struts like framework.- Invocation of EJB from servlet is one data flow direction. After EJB is invoked and finished, servlet gets results, makes its own job and sends data to clients either in html or binary AMF (Flex proprietary) format.
    - Invokation of servlet from EJB is another data flow direction. It will be employed, when server decides to inform all interested clients about an urgent event. Client are not asking for that event explicitly, but they are ready for handling such messages from the server.
    Of course, in order to achieve this, there is a need in a channel between server and each client. This is what BlazeDS for.
    The first requirement could be satisfied by either JNDI lookup or (as malrawi proposed) by dependency injection.
    The second one is a little bit harder... It may involve any other mediators, not necessarily the same servlets.
    I am looking for the best suitable solution now.
    Thanks,
    Alex.

  • Undeploy and redeploy in tomcat without tomcat manager

    My host is running Tomcat 4.1.24 on an Apache 1.3.29 server, and tomcat (supposedly) refreshes its servlets every twelve hours. If I upload a new .war file it will deploy it to a folder of the same name almost instantly, however if I then make changes to that .war file it will not deploy it over the old installation. This would lead me to believe I need to undeploy the old version of my webapp before the updated .war file can be deployed.
    It doesn't even deploy the updated .war file when tomcat refreshes, as I've waited over 12 hours without the updated .war file being deployed.
    Bearing in mind that I do not have access to my host's tomcat config files and, to make matters worse, they say they don't run the tomcat manager tool on their servers, how can I undeploy my old version of my webapp so that I can deploy the new one?
    Thanks,
    Andrew.

    Hmm, the crude way won't work, as the server won't let
    me overwrite the files, just as it won't let me delete
    them, and I can't get into my host's server.xml!
    You'd think they'd have servlet reloading on already.
    Don't think I'll be using them again.You can define your own Context fro each WAR without editing the server.xml
    For Tomcat 4, this means creating an XML that contains the <Context ...> element as defined HERE. You would make that context reloadable. The XML file will have to have the same name as the WAR. For existance, you want to make a Web App called MyCalendar. The War would be called MyCalendar.war and the XML file called MyCalendar.xml. The Contents of the MyCalendar.xml migh be as simple as:
    <Context docBase="MyCalendar" path="MyCalendar" reloadable="tru"></Context>

Maybe you are looking for