Servlet 3.0 async questions

i am experimenting with servlet 3.0 async with gfv3; my servlet's init() method is being called for each browser web request -- i thought only 1 init() call per servlet ??
destroy is only being called when i undeploy the servlets -- 2 servlets in 1 web app.
i am trying to experiment with all the options that apply to async support.
i have not figured how i am suppose to use AsycnContext.complete(); if i async.dispach to another servlet -- that servlet cannot
call AsyncContext.complete();
also --
the AsyncListener class -- has method onStartAsync() -- i am searching for a way to cause that method to be called ?
any help in understand will be appreciated.

I doubt anyone that is likely to read these forms has any direct knowledge in the technology you mention.
Here are some suggestions:
1: review any documentation that comes with the technology.
2: create simple projects to test how it works so you can isolate one issue at a time.
Run simple test scenarios against those simple projects.
3: pepper your code with System.out.println() statements so you can see what functions are called in what order.

Similar Messages

  • SSI with Servlet... tag question

    I've been trying to get the <SERVLET NAME=... tag working with WL5.1. After
              finding that the wall is indeed harder than my head after beating on it for
              a while, I need to cry for help. Can anyone spot what step I've missed? I
              used the Installshield setup, but I can't even get BEA's example SSI's to
              run for me.
              My WL5.1 doesn't seem to recognize the <SERVLET tag. My very simple .shtml
              file has: (it is shtml)
              <HTML>
              <HEAD>
              <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
              <TITLE>
              SSI test
              </TITLE>
              </HEAD>
              <BODY>
              this is in the HTML page only<P>
              <servlet name=test1 >
              this should not be seen<P>
              </servlet>
              this is in the HTML page only<P>
              </BODY>
              </HTML>
              and I get all three lines printed including the "this should not be seen",
              without output from the server. The servlet (test1) worked just fine in a
              normal servlet URL in a normal .html file (<FORM
              action=http://c00650:7001/test1 method="GET">).
              In the weblogic.properties file I have the following lines:
              weblogic.httpd.register.test1=com.eleris.bobtestservlet.Servlet1
              weblogic.httpd.register.*.shtml=weblogic.servlet.ServerSideIncludeServlet
              My classes are in
              H:\weblogic\myserver\servletclasses\com\eleris\bobtestservlet
              Can anyone tell me if you've seen this yourself, and what step I missed?
              

    Sorry, I don't think I can help you without more information.
    I created a simple Servlet, FooServlet, as follows:
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class FooServlet extends HttpServlet {
        public void service(HttpServletRequest req, HttpServletResponse res)
            throws IOException {
            PrintWriter out = res.getWriter();
            out.println("FooServlet");
    }I compiled FooServlet and placed FooServlet.class in /home/elving/app/WEB-INF/classes.
    I created /home/elving/app/index.html as follows:
    Top of index.html
    <!--#include virtual="/app/servlet/FooServlet"-->
    Bottom of index.htmlI defined a dummy web app in /home/elving/app/WEB-INF/web.xml:
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "file://d:/iplanet/bin/https/dtds/web-app_2_3.dtd">
    <web-app>
        <display-name>Foo</display-name>
    </web-app>I referenced the web app from server.xml:
    <WEBAPP uri="/app" path="/home/elving/app"/>I ensured that my server was configured to parse HTML files as SHTML (i.e. there is a type=magnus-internal/parsed-html exts=shtml,html line in my mime.types).
    However, accessing /app/ and /app/index.html produce identical, expected results, and nothing is logged to errors.

  • Setting up a servlet in iis

    Hello all
    I am new to servlets and my particular questions deals with setup. I have xp pro (iis 5.o) and I was wondering can I just install jre and put the servlet class on the server. I guess if someone can give a thought on that then I would be real appreciative

    I think IIS is a webserver only. You need to have some App Server or some servlet engine to be coupled with IIS. Try to get JRun/ Servlet Exec.

  • Problem setting up startup servlets in iWS 4.x

    I have configured iPlanet Web Server(iWS) 4.1 SP9 to use a startup servlet. However, the error log does not show that the servlet has been initialized. Instead, it shows only the following entries:
    Loading Simple Session Manager by default. Specify MMapSessionManager in servlets.properties to load persistent session manager
    I found in the Knowledgebase that we need to copy the the configuration entry that was created in context.properties file into the servlets.properties file
    My question that ...do we need to copy all the contents of the context.properties file or some portion of that file to servlets.properties .
    Please suggest asap, I cant take a risk as this is a live server.
    Thanks.

    Hi,
    You need not to copy entry file. In your servlets.properties file at the end of the file you can see the parameters settings of servlet which you have been configured as a servlet.
    For example the below setting are for "HelloWorldServlet" servlet configuration. You need to copy that line only.
    servlet.HelloWorldServlet.classpath=/export/home/41sp9/docs/servlet
    servlet.HelloWorldServlet.code=HelloWorldServlet.class
    Note: Make sure that before changing(copying)any changes in file take backup of the old file(present).
    Regards,
    Dakshin.
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support.

  • How can I import a servlet inside a JSP?

    Hi! I have seen tons of instructions on importing beans inside a JSP page but I want to use servlets instead. This question might be stupid, but I'm not really adept with JSPs yet and I hope you can help me.
    I need to import classes inside my JSP page so that I can use the methods and manipulate them through the JSP.
    Thank you!
    lauramos

    I'm curious, have you looked into using the MVC or Struts framework? One idea would be to map the Servlet you created to a JSP via XML (or any other mapping you want #?.jhtml for all that matters) and jsp:include as needed. Just a few mappings needed in WEB-INF/web.xml for instance...
    <servlet>
    ��<servlet-name>HeaderPageHandler</servlet-name>
    ��<servlet-class>packagename.HeaderPageHandler</servlet-class>
    </servlet>
    <servlet-mapping>
    ��<servlet-name>HeaderPageHandler</servlet-name>
    ��<url-pattern>/header_page.jsp</url-pattern>
    </servlet-mapping>
    In the JSP:
    <jsp:include page = "header_page.jsp" flush = "true" />
    The Servlet could forward the information over to another page using the getRequestDispatcher(String url).include(req, resp); From there, use the application or request scope to handle the jsp:useBean to output what you need. You could take that further and customize some of your own TLDs so you could state simple tags like <tag:output class="text">some text here</tag:output>

  • Trouble rationalizing use of multi-threading in run of the mill servlets

    Hey everybody,
    While spending time writing an internal wiki article on servlets for work, I asked myself a very basic question: What does multi-threading buy average servlets where the business logic requires procedural handling of the request?
    Don't get me wrong: I appreciate the fact that servlet containers spawning a new thread being less expensive than spawning an entirely new process is helpful and efficient. Coming from a background in PHP, it is great how servlets maintain persistence. However, as more of my coworkers are required to gain proficiency in Java and designing servlets, it is a question that many will ask and aside from having real-time processing of data files and other arduous tasks, I cannot think of any instances of where multi-threading benefits the application.
    What are some of the ways that you are using multi-threading with web applications?
    How would you explain why and where you would want to use multi-threading to someone?
    Thank you in advance for your insight,
    Andy

    how can we pass arguments to the run ()method?Create classes which implement Runnable that take your runtime parameters as constructor arguments and store them.
    eg: if your single thread method is   static void foo (int quantity, String name) {
        for (int i=0; i<quantity; i++) {
          System.out.println(name);
    // caller code
      foo(7, "wombats");Then you can make a runnable implementation thus:public class Foo implements Runnable {
      final int quantity_;
      final String name_;
      public Foo (int quantity, String name) {
        quantity_ = quantity;
        name_ = name;
      public void run () {
        for (int i=0; i<quantity_; i++) {
          System.out.println(name_);
    // caller code
      new Thread(new Foo(7, "wombats")).start();
    You could overload this method to take parameters in
    your class that implements the Runnable interface,
    and then call the base run() method.I don't get what you mean by this; Runnable is an interface so there is no base class run() method, and a run() overloaded with extra parameters method wouldn't get called by the thread.
    Pete

  • Question about Filter

    Hi there,
    If a Filter is mapped to a servlet, the request from browser will be processed by Filter first. My questions are:
    1) Can we set Filter to JSP or other static components?
    2) If the request is forward from another web component, will the request be processed by Filter? or Filter just works for request from browser?
    Thanks a lot!

    As usually the answer comes few hours after the question have been made ...
    I found this presentation:
    http://developers.sun.com/events/techdays/presentations/seattle/J2EEandAdvancedFeatures.pdf
    at page 7 you can read:
    One of the ambiguous areas in previous version of Servlet is in
    regard to the interaction between the RequestDispatcher and
    filters. Should filters invoke for forwarded requests? Included
    requests? What about for URIs invoked via the <error-page>
    mechanism? Before Servlet 2.4, these questions were left as open
    issues. Now Servlet 2.4 makes it a developer's choice. There's a
    new <dispatcher> element in the deployment descriptor with
    possible values REQUEST, FORWARD, INCLUDE, and
    ERROR.
    This means you need servlet 2.4 to manage the situation!

  • Deleting Cookies from Servlet

    hi
    i am working on JDeveloper 11.1.2.3
    i made a servlet filter and it works well but the problem is in the cookies ... i tried to delete the cookies from the servlet but in vain
    i uses this code but it does not work
    cookie.setMaxAge( 0 );
    Thanks

    Hi,
    Check
    http://stackoverflow.com/questions/3466267/problem-removing-cookie-in-servlet
    http://stackoverflow.com/questions/9821919/delete-cookie-from-a-servlet-response

  • Accessing Servlets from JSPs

    Hi!
    I'm developing a web application with JSPs and servlets using JDeveloper 3.2.
    With the integrated web-to-go web server I can either start a JSP environment or a servlet environment.
    My question: What do I have to do to start the JSP environment with access to servlets?
    I tried to start the wizard Web Object Manager, but I get the error message "Could not load servlet information from Web Server". When I try to register a Servlet in this wizard, it will hang up.
    What's wrong? Are there any other possibilities to configure the web-to-go web server, so that I can access JSPs and servlets?
    Thanks for your help!
    Brian

    Hi!
    I finally found the solution myself.
    The problem was that the entry "HTML source" under "Project Properties" was empty. I entered "servlets" and started the "Web Object Manager" without any problem. My servlet was registered and I could access it from my JSP.
    I hope that you can benifits from my experience.
    Cu
    Brian

  • How to process a form servlet

    I 've got a sample multiple choice form which I want to do this :write a servlet that processes the answers
    and returns a web page with the results of the test?
    Part code of the form.
    <form action=".../servlet/service" method="get">
    Question 5:To which address class does the IP address 126.11.4.3 belong?
    <td>
    <input type="radio" name="q17_choose1" id="q17" value="Class A">
    <label for="Class A">Class A</label> <br>
    <input type="radio" name="q17_choose1" id="q17" value="Class B">
    <label for="Class B">Class B</label> <br>
    <input type="radio" name="q17_choose1" id="q17" value="Class c">
    <label for="Class c">Class c</label> <br>
    </td>
    </table>
    </td>
    <input type="submit" value="Submit">
    </td>
    </tr>
    </table>
    </form>
    The servlet process side...
    part code.
    public void doGet (HttpServletRequest request,
    HttpServletResponse response
    )throws IOException, ServletException {
    // returns an enumeration of all the parameter names
    Enumeration aEnumeration = request.getParameterNames();
    String parameterName;
    String value;
    response.setContentType("text/html");
    PrintWriter aPW = response.getWriter();
    aPW.println( "<HTML><BODY>" );
    while ( aEnumeration.hasMoreElements() ) {
    parameterName = ( String )aEnumeration.nextElement();
    value = request.getParameter( parameterName );
    aPW.println( parameterName + " = " + value + "<BR>" );
    aPW.println( "</BODY></HTML>" );
    }

    Create 1 jsp page for the form , lets call it index.jsp , here's the code for index.jsp:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head><title></title></head>
      <body>
      <form action="target.jsp" method="get">
      Question 5:To which address class does the IP address 126.11.4.3 belong?
      <table>
      <td>
      <input type="radio" name="q17_choose1" id="q17" value="Class A">
      <label for="Class A">Class A</label> <br>
      <input type="radio" name="q17_choose1" id="q17" value="Class B">
      <label for="Class B">Class B</label> <br>
      <input type="radio" name="q17_choose1" id="q17" value="Class c">
      <label for="Class c">Class c</label> <br>
      </td>
      </table>
      <input type="submit" value="Submit"> 
      </form>
      </body>
    </html>Notice that the action of the form above is target.jsp , so now create another JSP page , call it target.jsp
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head><title></title></head>
      <body>
      <%=request.getParameter("q17_choose1")%>
      </body>
    </html>Assuming that you have set-up your webserver correctly , when you open index.jsp for example http://localhost:8080/index.jsp , it will show you the form with radio buttons and a submit button.
    When you click on submit, it opens target.jsp , which then shows the radio button you selected on index.jsp.

  • Instantiating bean in Servlet

    Hi All
    I have written a bean that fetches data from another java class. My Servlet instantiates that bean and pass that object reference to another Java class, which is multi-threaded. One thread of that class calls another method of another object using that object reference. so, in that way the object reference of that bean (which is created by the servlet) is passed all over the application and fetches data from there to show in the Servlet.
    Now my question is, as Servlet is multithreaded by default, it should create an instance of that bean everytime the servlet is accessed (not by calling from that servlet or any other servlets/JSPs)by different users. And by this way every servlet should have their own bean instances. In my case, when I am running that servlet in my localhost it works fine but at the same time when I try to invoke that servlet again from another browser it passes the bean object reference as null. I dont really understand that. Currently I am creating the bean instance in the class definition. I tried to create the instance in init() method but the problem remains same. If my approach is wrong then where should I create the bean instance.
    Thanks in advance.
    Regards
    Anirban

    Thanks very much.
    I have no service method. I have doGet() and doPost() method. doGet is called just once to create the login screen in every session. doPost handles the form data and it is called several times.
    should I create the bean instance in doGet method then? I have to pass that object reference as an object array in that method parameter. where should I initialize that object array and create the instance of the bean and pass the array to another method. I am passing that object reference to another java class method in doget() method.
    Cheers!!
    Anirban

  • Where is a Servlet instance stored in Tomcat?

    Hi,
    We know that servlet container generates ONLY ONE servlet instance which will handle all the client requests for the servlet. This makes big inconvenionce in debug phase using Tomcat server. Unless restarting the server, you will not be able to see the changes you made in the servlet class.
    My question is where the servlet instance is stored in Tomcat. I think it should be in [TOMCAT_HOME]/work/ directory but actually not. My approach is deleting the instance before sending request to the servlet. In this way, servlet container will generate an instance of new version of the servlet class.
    Is there any other way to work around that?
    Thanks,

    We know that servlet container generates ONLY ONE
    servlet instance which will handle all the client
    requests for the servlet. My Tomcat instance will pool servlet instances. It might look like only one instance to you, but that doesn't mean that Tomcat does it that way.
    This makes big inconvenionce in debug phase using Tomcat server. This makes no sense to me. Are you talking about load testing?
    Unless restarting the server, you will not be able to see the changes you made in the servlet class.This has nothing to do with debugging. And Tomcat has hot deployment now if you do it correctly with WAR files.
    My question is where the servlet instance is stored in Tomcat. I think it should be in
    [TOMCAT_HOME]/work/ directory but actually not. My approach is deleting the instance before sending
    request to the servlet. In this way, servlet container will generate an instance of new version of the
    servlet class.Sounds like you don't know how to deploy to Tomcat properly. Servlet .class files are stored where you put them: in the WEB-INF/classes directory for your Web app, in a JAR in the WEB-INF/lib directory for your Web app. These are either in the TOMCAT_HOME/webapps context directory that you create or, better yet, in the WAR file that you deploy to TOMCAT_HOME/webapps.
    The /work directory that you refer to is where Tomcat puts generated Java code for JSPs.
    Is there any other way to work around that?There's no way to change it, and there's no reason that I can think of to explain why you'd want to. What is the real problem here?

  • Specifying servlet classpath in xml file

              Hi there...
              Am trying to achieve dynamic class reloading for my web application, and have
              specified the servlet classpath in my web.xml file. However my server still loads
              classes that exist on the classpath first, and ignores any 'later' versions I
              have placed in the servlet classpath.
              My question would be do I really have to split up my jar files and place the individual
              classes on the servlet classpath, or can I specify two or more parameters under
              the "context-params" in the web.xml.
              Ideally I would like to be able to keep my jars whole, and upload classes to override
              the contents of the jar, and at the moment I can't see a way to achieve this !!
              Many thanks for any help anyone might be able to give !!
              George
              

    I'm no expert with WAR files and 5.1 but....
              Have you tried putting your jar files and any non-weblogic specific jars in
              to your WEB-INF/lib directory?
              Then you dont have to specify them in the classpath when starting weblogic.
              Following this - i think you should be a step closer to dynamic class
              reloading.
              "George Cover" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Thanks for the prompt response...unfortunately we are still at version 5,
              with
              > a service pack level of 10 (which has just gone live). However we do have
              our
              > environments set up as much as possible in a J2EE fashion.
              >
              > We still specify a classpath, where the jars are kept, however we also
              have WEB-INF
              > directories, where compiled classes (jsp, and shock horror, jhtml) are
              kept !!
              >
              > I think that placing classes in here, puts me in a similar situation as
              placing
              > them on the servlet classpath, the jars still override them !!
              >
              > Also the halfway house our server environments are in, plus the fact they
              are
              > all constantly changing, makes it difficult to predict behaviour, or even
              come
              > close to understanding what might happen if I change configurations here
              and there
              > !!
              >
              > Many thanks
              > George
              >
              > "Matt Krevs" <[email protected]> wrote:
              > >What version of weblogic are you using?
              > >
              > >If you are using 6.0 or greater - my understanding is that you dont
              specify
              > >your classes in the classpath when starting weblogic. Your classes and
              > >jars
              > >should be in web-inf/classes and web-inf/lib and should be loaded from
              > >there.
              > >
              > >"George Cover" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> Hi there...
              > >>
              > >> Am trying to achieve dynamic class reloading for my web application,
              > >and
              > >have
              > >> specified the servlet classpath in my web.xml file. However my server
              > >still loads
              > >> classes that exist on the classpath first, and ignores any 'later'
              > >versions I
              > >> have placed in the servlet classpath.
              > >>
              > >> My question would be do I really have to split up my jar files and
              > >place
              > >the individual
              > >> classes on the servlet classpath, or can I specify two or more
              parameters
              > >under
              > >> the "context-params" in the web.xml.
              > >>
              > >> Ideally I would like to be able to keep my jars whole, and upload
              classes
              > >to override
              > >> the contents of the jar, and at the moment I can't see a way to achieve
              > >this !!
              > >>
              > >> Many thanks for any help anyone might be able to give !!
              > >> George
              > >
              > >
              >
              

  • Howto free resources when servlet reaches timeout?

    Hi there!
    I have written a small servlet which is mainly used to communicate via different types of clients using http.
    SoI only use the servlet as a "http-receiver", behind there works a complex buissnes logic withought any servlet/jsp/j2ee-stuff.
    I know these are basic questions but till now I did not find any answer to the following questions:
    1.) How can I change the session-timout?
    2.) How can I release resources (db-connections, ....) after session timeout exceeded?
    Maybe you know a servlet-tutorial which covers questions like the quests above, such a tut would help a lot ;-)
    Thanks a lot, lg Clemens

    1) you can set the session timout either in code with session.setMaxInactiveInterval(), or in the web.xml with the <session-timeout> element.
    2) The HttpSessionBindingListener interface has a method called valueUnbound() that gets called when the session expires. You can use that method to release resources. Define a timeout notifier class implementing the HttpSessionBindingListener interface. Create an object of that new class and add it to the session. When the session times out, your notifier's valueUnbound() will be called .
    Don't forget to add you notifier class in the listener tag of the web.xml :
    <listener>
      <listener-class>package.notifierClass</listener-class>
    </listener>As for some doc, this one should do it.

  • Servlet architecture

    Hi sun ,
    i am learning j2ee1.4 . i am able to code servlet program and jsp program bur i am getting confuse in the architecturial part of the servlet and jsp.
    my question is when i am hiting one servlet class file from my browser after hitted how the servlet flow and how it will give response to the browser again ?
    here how servlcontainer works over in this situation ?
    How servlet container is diffrent from servlet engine .

    The best thing you can do is read the Servlet Specification at http://java.sun.com/products/servlet/reference/api/index.html on the servlet life cycle.
    Servlet Engine is most of the times used as a synonym for Servlet Container.
    Cheers,
    --Arnout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Can i use subfolders with source control for developer ?

    We'd like to use the repository as source control for our developer files. We planned to use the following structure in the repository: - Application Container - Folder - Files We uploaded the files in the repository. Now if we open the file through

  • I am using Mac OS X 10.6.8 flash player is not working!

    Hello, Out of the blue i realize i do not see in website flash buttons, intros etc..? i have install Adobe Flash Player 11.8.800.94 why this is happening.... it i sa huge problem to me. Please if any knows why... help me. thank you in advance

  • Viewing PSD thumbnails in a directory

    I'm using Photoshop CS 4. When viewing PSD file thumbnails ina directory I cannopt see the actual image - just a PSD label.  Is this functioning correctly? Why can't I see a PSD thumbnail in Photoshop?

  • Incomplete Export w/Compressor

    I'm new to Compressor. Everything makes sense except the export is acting odd: I am exporting several separate projects (under 15:00 minutes) directly from FCP to Compressor 2.0.1, for DVDSP. The shortest project (5:00) exported fine but only a porti

  • Not publishing entire site with all pages from site studio Designer

    Hi, I have created the site with one primary page & one secondary page in the site designer. I must admit that they don't have link to each other. When I publishing this site using Oracle Site studio publishing utility to a subscriber, it is publishi