Tomcat 4.0,Servlet 2.3 and JSP1.2

Trying to figure out what to do with the Servlet 2.3 and JSP 1.2 zip files. Have the JDK 1.4 and Tomcat 4.0 already installed. Cant find any instructions at all on the java website on where to unzip the classes. JDK1.4/lib?Thanks in advance.

Thanks for the reply. So then where do the javax.* classes reside? How does the servlet.java file find the imported servlet classes when the pgm is compiled? Why is java such a PITA to get up and running? Sorry. I keep getting:
A Servlet Exception Has Occurred
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
if (pageContext != null) pageContext.handlePageException(t);
when I try to run a .jsp with tomcat.

Similar Messages

  • New error with upgrade jboss/tomcat: "Connection handle has been closed and is unusable"

    Hi,
    This error suddenly appeared when we upgraded from jboss3/tomcat5.0 to jboss4.2/tomcat5.5.
    here's the usecase:
    1) User clicks on report link
    2) Crystal reports web componnent displays screen to fill in report parameters.
    3) user enters parameters and clicks submit
    4) System throws Exception
    The same reports worked fine with jboss 3.2.6/tomcat 5.0. We haven't touched anything in this realm.
    Log Excerpt:
    09:42:18,842 INFO  [datasource] Openning rowset
    09:42:18,904 ERROR [reportdefinition] com.crystaldecisions.reports.queryengine.driverImpl.m: JDBC Error: Connection handle has been closed and is unusable
    09:42:18,905 ERROR [datasource] Failed to open rowset: the query failed to open rowset
    com.crystaldecisions.reports.reportdefinition.datainterface.g: JDBC Error: Connection handle has been closed and is unusable
         at com.crystaldecisions.reports.reportdefinition.datainterface.d.a(Unknown Source)
    To try to narrow down the problem, I've updated the jdbc configuration to
         <track-statements>true</track-statements>   
    here's a recap:
    This Boolean element specifies whether to check for unclosed statements when a connection is returned to the pool. If it is true, a warning message is issued for each unclosed statement. If the log4j category org.jboss.resource.adapter.jdbc.WrappedConnection has trace level enabled, a stack trace of the connection close call is logged as well. This is a debug feature that can be turned off in production.
    Interestingly enough, this error appears slightly upstream:
    (CachedConnectionManager.java:526) - Closing a connection for you.  Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@c76003
    java.lang.Throwable: STACKTRACE
         at
    org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
         at com.crystaldecisions.reports.queryengine.driverImpl.k.a(Unknown Source)
         at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
         at com.crystaldecisions.reports.queryengine.av.new(Unknown Source)
         at com.crystaldecisions.reports.queryengine.av.byte(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
         at com.crystaldecisions.reports.dataengine.ba.try(Unknown Source)
         at com.crystaldecisions.reports.common.av.a(Unknown Source)
         at com.crystaldecisions.reports.common.ag.a(Unknown Source)
         at com.businessobjects.reports.sdk.b.e.a(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown
    So the question arises:
    1) Is the jboss datasource overly/aggressively closing result sets?
    2) or is there a coding error in CRXIR2?
    thanks,
    bill
    Full stack trace:
    [2008-03-13 17:26:18,905] [INFO ] org.jboss.resource.connectionmanager.CachedConnectionManager (CachedConnectionManager.java:526) - Closing a connection for you.  Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@c76003
    java.lang.Throwable: STACKTRACE
         at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290)
         at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:417)
         at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
         at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
         at com.crystaldecisions.reports.queryengine.driverImpl.k.a(Unknown Source)
         at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
         at com.crystaldecisions.reports.queryengine.av.new(Unknown Source)
         at com.crystaldecisions.reports.queryengine.av.byte(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
         at com.crystaldecisions.reports.dataengine.ba.try(Unknown Source)
         at com.crystaldecisions.reports.common.av.a(Unknown Source)
         at com.crystaldecisions.reports.common.ag.a(Unknown Source)
         at com.businessobjects.reports.sdk.b.e.a(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.y.a(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.cf.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.z.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ak.if(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ad.int(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.bk.for(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.v.a(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.v.if(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.setTableLocation(Unknown Source)
         at com.crystaldecisions.reports.sdk.DatabaseController.setTableLocation(Unknown Source)
         at org.apache.jsp.reports.processreport_jsp.switchTables(processreport_jsp.java:131)
         at org.apache.jsp.reports.processreport_jsp.loadReport(processreport_jsp.java:68)
         at org.apache.jsp.reports.processreport_jsp._jspService(processreport_jsp.java:227)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.participate.shared.pagecache.client.PageCacheFilter.doFilter(PageCacheFilter.java:760)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.participate.util.servlet.ExpiredPasswordFilter.doFilter(ExpiredPasswordFilter.java:92)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.participate.pe.channels.client.servlet.ChannelUrlFilter.processUrl(ChannelUrlFilter.java:168)
         at com.participate.pe.channels.client.servlet.ChannelUrlFilter.doFilter(ChannelUrlFilter.java:100)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.participate.util.servlet.BlockIpAddressFilter.doFilter(BlockIpAddressFilter.java:224)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.outstart.multiapp.filters.KeepOtherSessionsAliveFilter.doFilter(KeepOtherSessionsAliveFilter.java:88)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.participate.util.servlet.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:151)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Thread.java:619)

    <p>
    OK. I found the problem along with a workaround.
    </p>
    <p>
    <strong>The problem:</strong>
    </p>
    <p>
    a programming practice clashes with a new jboss 'safety check'.
    </p>
    <p>
    <strong>Programming practice:</strong>
    </p>
    <p>
    crystal reports gets a database connection in one jsp page, then tries to use it on another jsp/servlet
    </p>
    <p>
    <strong>Jboss safety check:</strong>
    Jboss/tomcat new comes configured out-of-the-box with a 'cached connection
    manager', which
    </p>
    <p>
    "Check[s] for unclosed connections and transaction terminated checks in servlets/jsps."
    </p>
    <p>
    <strong> Summary</strong>
    </p>
    <p>
    In short, if a servlet/jsp ends and it leaves a database connection open, Jboss will automatically close it.
    </p>
    <p>
    </p>
    <p>
    <strong>Workaround:</strong><br />
    Comment out two entries in these two files:
    </p>
    <p>
    1) conf/jboss4/pe/deploy/jboss-web.deployer/server.xml
    </p>
    <p>
    2) conf/jboss4/pe/deploy/jboss-web.deployer/META-INF/jboss-service.xml
    </p>
    <p>
    The two entries:
    </p>
    <p>
    </p>
    <p>
    1)
    </p>
    <p>
                 <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"<br />
                    cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"<br />
                    transactionManagerObjectName="jboss:service=TransactionManager" /><br />
    </p>
    <p>
    2)
    </p>
    <p>
          <depends>jboss.jca:service=CachedConnectionManager</depends><br />
    </p>
    <p>
    </p>
    <p>
    <strong>Comments on the workaround</strong>
    </p>
    <p>
    The 'cached connection manager' basically makes sure that the application cleans up after bad programmers. It seems most helpful in development, load testing, or trouble shooting.
    </p>
    <p>
    In production,  you can likely  comment them out with minimal
    impact on the application.
    </p>

  • Loading remote EJB from servlet using jakarta and openejb

    I am trying to create an environment where I use
    openejb as my EJB container, and JAKARTA Tomcat
    as my
    Servlet/JSP container. However,
    i'm having a problem in lookingup my remote EJB from my
    jakarta application.
    That exact code works perfectly if I run it standalone. I
    am using the same JRE. Jakarta has also loaded the
    openejb-0.8.3.jar and openejb_client-0.8.3.jar
    What I dont understand is why jakarta
    would behave differently than command-line java when I
    am
    running in the same JRE on a single machine.
    Any help would be much appreciated.

    Several fairly major improvements have been maid in OpenEJB specifically for the Tomcat people. For one, the whole way you integrate them has completely been rewritten. Now all you have to do is copy a openejb_loader-0.9.1.war into the Tomcat webapps directory and change an init-param in it. Pretty straight forward. OpenEJB 0.8.3 won't work with Tomcat in the same VM, however OpenEJB 0.9.0 and up have been totally revamped in all things related to classloading so that it can co-exist with Tomcats unique classloading architecture.
    O'Reilly just published an article detailing the ins and outs of the integration, it's a pretty good read:
    http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html

  • Tomcat embedded + add servlet

    Hi,
    I need to use Tomcat in an embedded mode. No problem to do this. The only problem is that I want to have a servlet added to the server at startup coding it directly in my start method. I have saw that it is possible with Jetty, is it possible too with Tomcat ?
    Thanks.

    Hi,
    download the Tomcat "Embedded" version at http://tomcat.apache.org/download-55.cgi and try the following code:
    import org.apache.catalina.*;
    import org.apache.catalina.connector.*;
    import org.apache.catalina.realm.*;
    import org.apache.catalina.startup.*;
    import org.apache.catalina.users.*;
    public class EmbeddedTomcat
      // Instance variables:
      private String    name;
      private int       portNumber;
      private Embedded  embedded;
      private Engine    baseEngine;
      private Host      baseHost;
      private Connector httpConnector;
      /** Creates a new instance of EmbeddedTomcat */
      public EmbeddedTomcat(
        String name,
        int    portNumber)
        this.name = name;
        this.portNumber = portNumber;
        init();
      private void init()
        MemoryRealm realm;
        Context     context;
        String      baseEngineName;
        String      hostName;
        embedded = new Embedded();
        // set default logger and realm
           FileLogger fileLog = new FileLogger();
           fileLog.setDirectory(".");
           fileLog.setPrefix(name);
           fileLog.setSuffix(".log");
           fileLog.setTimestamp(true);
           embedded.setLogger(fileLog);
        realm = new MemoryRealm();
        embedded.setRealm(realm);
        // create an Engine
        baseEngine = embedded.createEngine();
        // set Engine properties
        baseEngineName = name + "Engine";
        hostName = name + "Host";
        baseEngine.setName(baseEngineName);
        baseEngine.setDefaultHost(hostName);
        baseHost = embedded.createHost(hostName, "webapps");
        baseEngine.addChild(baseHost);
        // RootContext
        context = addContext("", "ROOT");
        // ManagerContext
        context = addContext("/manager", "manager");
        context.setPrivileged(true);
        // add new Engine to set of Engine for embedded server
        embedded.addEngine(baseEngine);
        // create Connector
        httpConnector = embedded.createConnector((java.net.InetAddress) null,
            portNumber, false);
        // add new Connector to set of Connectors for embedded server, associated
        // with Engine
        embedded.addConnector(httpConnector);
      public void start()
        // start server
        try
          embedded.start();
        catch (org.apache.catalina.LifecycleException ex)
          ex.printStackTrace();
          //fileLog.log("Startup failed");
          //fileLog.log(ex.getMessage());
      public Context addContext(
        String path,
        String docBase)
        Context c;
        c = embedded.createContext(path, docBase);
        baseHost.addChild(c);
        return c;
      public static void main(String[] args)
        new EmbeddedTomcat("test", 8080).start();
    }Let me know if you have any problems.
    /klejs

  • Tomcat: reloading modified servlets?

    hi
    in tomcat it's possible to configure a servlet context to automaticaly reload if the servlet was rebuild. i know how to do that and i works.
    what i want to change is the reation time of tomcat. it sometimes takes quite a long time till tomcat realizes that a servlet has changed and reloads it. I think that mechnism is quite simple, kind of a thread that looks for a new modifed date of the servlet file and reloads or not and goes to sleep again for a amount of time. My question: is there a possibility to configurate that parameter that handels the sleep time?
    thanx for your help!

    If you get hold of the source (this is from v4.0.4)
    Look in org.apache.cataline.loader.StandardLoader.java
    you will see at line 164 that this value has a hard coded default of 15 (seconds).
    There is a public void setCheckInterval(int checkInterval) but I'm not sure where you can configure this to be set - I can't find any classes which call it.
    It might be possible to access the loader from a servlet run at start up with an init() method that sets a new value.
    HH

  • Servlets, Threads, sleep and wait

    Hi,
    I am new to servlet programming and have a problem.
    I want to create a servlet that is also Runnable. It should hold the HTTP request open, and then wait() or sleep(), waking up regularly to send data to the client.
    My code seems to work OK, and in the server logs I can see the debug messages where my servlet is sleeping and waking up. However, it doesn't keep the connection open. Instead, any clients that try to connect instantly receive an empty response.
    Can anyone explain why this is? I am a bit lost. Is the server (Tomcat) cutting my request off when I start to sleep or what?
    dave

    OK. Now seems like I have it working with sleep().
    I was doing something pretty dumb and assuming that a new HttpServlet instance was created for every request - doing things like this.request = request; - obviously this didn't work too wlell ;-)
    Now just using Thread.sleep() it works much better
    One more question - how can I get a separate servlet to call notify() on this servlet so that it wakes up and delivers its message? (I know I need to call wait() not sleep())
    Thanks
    dave

  • How Tomcat Webserver Create objects of ServletRequest and Response

    Tomcat webserver creates objects of ServletRequest and Response before calling the service method
    How the statement is declared plz help me

    ServletRequest and ServletResponse are interfaces. They are part of the Servlet API. Another parties can implement the API to their taste. Such as Apache Tomcat and Sun Glassfish. Apache Tomcat has its own implementations of the both interfaces, for example the org.apache.catalina.connector.Request and org.apache.catalina.connector.Response.
    So they can just do it like follows:
    javax.servlet.ServletRequest request = new org.apache.catalina.connector.Request();Apache Tomcat is open source. You can download the sources and look how they did it.
    Having said that, whenever someone asks this question, they generally want to be able to create the ServletRequest in a plain vanilla Java class outside the ServletContext. Is this true? If so, please elaborate about your actual problem. Just because this indicates a bad design.

  • Hi frnds i want to help in servlet,java bean and JSP

    hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
    so pls give me a title about that
    NOTE: I develop a project in group(2 persons there)
    my email id is : [email protected] , [email protected] , [email protected]

    You cannot pair your iPod to a cell phone, so forget about it.
    The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve....

  • How to create the servlet as acontroller  and how to use it

    how to create the servlet as acontroller and how to use it

    >
    John
    Please update your forum profile with a real handle instead of "914824".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I am going to have over 50 buttons in a page, Why? This would be a most unusual UI paradigm. I've never seen such a page, which suggests that whatever you want to do is normally done another way. Please explain the requirement in more detail.
    just wanted to know if its possible to do something like this in java.
    Java is not used in programming APEX UI behaviour. Java and JavaScript may share initial syllables, but they are not closely related.
    It's possible to achieve a great deal in JavaScript, but a clear definition of the requirements is necessary. Do you mean the buttons should be dynamically generated? If so, yes, this is possible in JavaScript. What would drive the process?
    Also, i would like to have dynamic action on it, for example, when the button is pressed, fill a string of text into other items(text field) within the page. Without more detail its not possible to make any specific suggestions. For example, I certainly would not want to create 50+ individual dynamic actions relating to different buttons.

  • Write a servlet without doGet() and doPost() methods

    Hi,
    Can we write a servlet without doGet() and doPost() methods ?

    public class MyCoolServlet extends HttpServlet
    public void init(ServletConfig servletConfig) throws ServletException
    public void service(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
    // your code here
    }Just an example on how to do it.
    A servlet is loaded by server (before any request). It will run the init function. Then pick up an request, spawn a thread and put this servlet code into the thread, give it session, request and response objects, then call serivce.
    Remember that init is called before, outside the thread, while service is inside the thread and the last to be called. Nice place to put your code.
    If you need to have some sort of init function to be called first on every request PR USER, then make your own function, and call it first in service method.
    Stuff that are put in init() function might only get runned once in the entire server lifetime. Until restart.

  • How get xml-data at servlet by http and parse it?

    hello! please help me who can, i have very urgent task but not much skilful to deal with work in web. is anywhere source code or similar example of task to get xml-data at servlet by http and parse it . thank you in advance

    here a basic code that reads and parses an remote xml file:
    import java.io.IOException;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    public class SAXParserExample extends DefaultHandler {
         StringBuffer buffer;
         String urlString = "http://nds.nokia.com/uaprof/NN95_8GB-1r100.xml";
         public SAXParserExample() {
         public void runExample() {
              parseDocument();
         private void parseDocument() {
              // get a factory
              SAXParserFactory spf = SAXParserFactory.newInstance();
              try {
                   // get a new instance of parser
                   SAXParser sp = spf.newSAXParser();
                   URL url = new URL(urlString);
                   HttpURLConnection httpSource = (HttpURLConnection) url.openConnection();
                   // parse the file and also register this class for call backs
                   sp.parse(httpSource.getInputStream(), this);
              } catch (SAXException se) {
                   se.printStackTrace();
              } catch (ParserConfigurationException pce) {
                   pce.printStackTrace();
              } catch (IOException ie) {
                   ie.printStackTrace();
         // Event Handlers
         public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
              System.out.println("+++ start of element: " + qName);
              buffer = new StringBuffer();
         public void characters(char[] ch, int start, int length) throws SAXException {
              buffer.append(ch, start, length);
         public void endElement(String uri, String localName, String qName) throws SAXException {
              System.out.println(buffer.toString());
              System.out.println("+++ end of element " + qName);
         public static void main(String[] args) {
              SAXParserExample spe = new SAXParserExample();
              spe.runExample();
    }you have only to change the urlString and adapt to your needs.
    hope it helps

  • Post XML to Servlet through JavaScript and reveive info back

    There's a post in this forum before, but anyone know how to do this:
    =========================================
    MSIE5 + will let you post an XML string to a servlet. It must be done from javascript. The same javascript can also receive an xml string back from the servlet, parse it, and update dom objects in the browser, independenty of a an http post.
    You can use this technique to populate ddlb based on events in the browser, or do real-time validations from the database. It works just fine, is quite fast, but is MSIE specific. If another brower is used, you must handle it some other way.
    =========================================
    I will use IE only.
    Any help will be highly appreciated!
    Charles

    Thanks for your response, ddossot!
    I also got something from our Microsoft team, post here to share with others who have interest in this topic. It's interesting to see IE talk with Servlet in XML, especially within a LAN.
    ==============================================================================
    I did find a couple of things. Not sure if it is exactly what you are looking for. Let me know if it works.
    function submitAsXML() {
         var theXML = document.myform.txtInXML.value;
    var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         var url = document.myform.txtURL.value;
    try {
    xmlhttp.open("POST", url, false);
    } catch(e) {
    xmlhttp.open("POST", url, false);
    xmlhttp.Send(theXML);
         var xmlResp = xmlhttp.ResponseText;
         document.myform.txtOutXML.value = xmlResp;
    Link to XML DOM Properties -
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmproresponsexmlserverxmlhttp.asp
    Regards,
    Ashwin

  • Sending data to a Servlet. EOFException and StreamCorruptedException.

    Hi!
    I have a small servlet that receives some text from a client, and returns a response. The problem is that when i try to receive the data in the servlet, I get and EOFException. And when the client tries to read the response, a StreamCorruptedException is thrown. Can anybody please point me in the right direction here?
    The code for servlet is as follows:
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              DataInputStream in = new DataInputStream((InputStream) request.getInputStream());
              String message;
              String text = null;
              try {
                   text = in.readUTF();//EOFException thrown here!
                   message = "100 ok";
              } catch (Throwable t) {
                   message = "200 " + t.toString();
              response.setContentType("text/html;charset=UTF-8");
              response.setContentLength(message.length());
              in.close();
              PrintWriter out = response.getWriter();
              out.println(message);
              out.flush();
              out.close();
              System.out.println(". Received text: " + text == null ? "none" : text);
         }And the code for the client:
         @Test
         public void test2() throws IOException, ClassNotFoundException {
              String input = "This text is to be sent";
              URL serverURL = new URL("http://localhost:8080/myURL");
              URLConnection con = serverURL.openConnection();
              con.setDoInput(true);
              con.setDoOutput(true);
              con.setUseCaches(false);          
              con.setRequestProperty("Content-Type", "application/x-java-serialized-object");
              OutputStream outstream = con.getOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(outstream);
              oos.writeObject(input);
              oos.flush();
              oos.close();
              InputStream instr = con.getInputStream();
              ObjectInputStream inputFromServlet = new ObjectInputStream(instr);//StreamCorruptedException thrown here ("invalid stream header")
              String result = (String) inputFromServlet.readObject();
              inputFromServlet.close();
              instr.close();
              System.out.println(result);
         }The EOFException is thrown at the line text = in.readUTF(); in the servlet, and the StreamCorruptedException is thrown at ObjectInputStream inputFromServlet = new ObjectInputStream(instr); in the client. What is wrong here?
    Edited by: Fush on Apr 15, 2008 6:59 AM
    Edited by: Fush on Apr 15, 2008 7:00 AM
    Edited by: Fush on Apr 15, 2008 7:03 AM

    Your server reads a UTF-encoded String with readUTF().
    So your client should write a UTF-encoded String with writeUTF().
    Your server writes lines with PrintWriter.println().
    So your client should read lines with BufferedReader.readLine().

  • How do I get the Tomcat port using Servlet.

    I am running Apache + Tomcat. All request are going though Apache. How do I get the Tomcat port using Servlet.

    See:
    ServletRequest.getServerPort()This will give the port upon which the request was recieved . . .which I blelieve is what you are looking for.

  • Servlet - JSP design and performance (Tomcat)

    Hi everybody.
    I'm new in Tomcat and servlet/JSP development.
    My current design involves only one servlet (does the business logic, JSP page selections) which delegates the requests to several JSP-s (the JSP-s are included with the "jsp:include" tag).
    The questions:
    1. Has this design some performance drawbacks in contrast with a design in which several servlets are used (some of the included JSP pages will be the same)?
    2. How Tomcat resolves concurent requests (if the same servlet is involved or two separate servlets are involved)?
    Any response is greatly appreciated.
    Thanks.

    A few things to keep in mind:
    Every JSP is really a Servlet. Behind the scenes, these are compiled into Servlets which are then run. So, you really do have an implementation with more than one Servlet.
    Controller Servlet's (one per JVM) are a very popular architecture choice. Struts, Spring and a number of other frameworks use this model. There should not be a difference between running multiple versus a single Servlet, and even if there is, your application undoubtedly has scaling bottlenecks other than this (probably orders of magnitude higher) than worrying about this particular issue.
    Tomcat dispatches the request to whatever Servlet satisfies the servlet-mapping that the URL matches. Since Servlet's are designed to be written thread-safe, and since the container will manage those instances, do not worry.- Saish

Maybe you are looking for

  • ITunes doesn't see any of my devices.

    I have just got the iPhone 5S, but my itunes wont see any devices. I can see it on my device list in windows. I have stoped and restarted the apple device service thing but this didnt help. I have also reinstalled iTunes. Im running window 8.1 RT

  • "Help" error 404 in Dreamweaver CS6

    I have just purchased Dreamweaver CS6 after more than twelve years of web-site development using NetObjects Fusion and hand-coding. Conscious of the step-up in possibilities offered by CS6, I am keen to learn as I go (un-learning my existing bad habi

  • Another dead 40 G - Is there a solution for this?

    Hi, I'm about to receive my second replacement for the 4th generation 40 G ipod. My first 40 G lasted for more than one year, this second one has only lasted 7 months. I've always treated my ipods better than my own daughter. After the first break, I

  • Phone wakes from sleep by itself

    Usually after hitting the sleep/wake button my phone wakes up again. I have not touched the home button or sleep button and it is not an everyday problem it is just random I have restored it but no luck any help thanks

  • Help - "sync" with .Mac webmail, and incorrect delivery to alias in Mail

    I have just started using .Mac IMAP accounts in Apple Mail (previous experience with another ISP with POP only). Two questions: 1. Since this is an IMAP account, when I delete a message on my computer in Apple Mail, will this deletion automatically a