New instance for every request to Servlet

I want to create new instance for every request to Servlet ...
I am running my servlet on weblogic

Hi!
what functionality can there be that has to be put into init()?
Another idea:
why not include your needed functions in a private method within the servlet and call this method from init() and from doPost/doGet so it is processed any time the servlet is called?
btw: more instances of the same servlet seems to me as going back to the roots (cgi).
Thomas.

Similar Messages

  • How to generate a new rhread for every request

    Hello,
    I'm trying to write a server side program that does the following, recieves a Single connection from a client, client sends a request to the server side program, the server side program sends to a third party(back end) and waits for a reply.
    The problem i am facing is the following, I want to for each message(request) recieved from the Client to generate a new thread and establish a new connection with the third party, I have tried creating a new thread for the communication with the third party, in this case if the response from backend takes time I will still be able to recieve other requests from the client. But I dont know how to return the message that his been to the Father thread. The reason why I am doing this is that I dont want the same thread that recieves the request from client to wait until the reply for the previous thread is sent.
    Here's the code which I have been trying to implement.
    ClientCommunicator {
    Socket soc= new Socket(IPAddress,port);
    Thread backEndComm= new Thread (new BackEndCommunicator
    (soc,"Message To Back End"));
    backEndComm.setPriority(8);
    backEndComm.start();
    public class BackEndCommunicator implements Runnable
    Socket socket;
    String messageToBeSentToBE= "";
    public BackEndCommunicator(Socket socket, String messageTOBE)
    this.socket= socket;
    messageToBeSentToBE= messageTOBE;
    public void run()
    PrintWriter outtBackEnd= null;
    BufferedReader innBackEnd= null;
    String replyFromBE= "";
    try
    outtBackEnd= new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
    outtBackEnd.println(messageToBeSentToBE);
    outtBackEnd.flush();
    innBackEnd= new BufferedReader(new InputStreamReader(socket.getInputStream()));
    replyFromBE= innBackEnd.readLine();
    How can I return the String "replyFromBE" to the ClientCommunicator class so it can be sent to the client as soon as recieved from the back end.
    regards,
    [email protected]

    I assume the problem you are having is that your ClientCommunicator thread is blocking in a read and has no way of receiving notification from the other thread. Seems like you have a couple options at least.
    1. Use non-blocking IO and a selector to do service both the client socket and the backend socket. Usually, NIO is more of a pain than it is worth unless you need to service hundreds of connections at once, but I think that in this case where you know that there are only two connections it might be easy enough to use.
    2. A second option would be to avoid blocking on the read by using the available method on the input stream to first determine if you can actually read anything. This would allow you to wait with a small timeout on a monitor that the backend communicator could notify when it receives a response. This is not the ideal solution because you are limiting how fast you respond to the client and could be using more cpu time than necessary. However, it might be a lot easier to implement and could be adequate for what you need.
    First solution is more elegant but potentially not worth the trouble. Second solution is less elegant, but may be good enough.

  • A new socket for every http-request?

    Do I have to make a new socket for every http-request? The code below doesn't work because it is two requests in a row. The first GET works, but the second doesn't. I thought that the purpose of a socket is that you set it up once and then you should be able to do arbitrary communication between the two peers. Maybe that is just the case with sockets only but not if you use sockets to perform http.
    Thank you for your answers! Nice greetings from Austria (not Australia)!
    Stefan :)
    package httptest;
    import javax.net.ssl.*;
    import java.io.*;
    import java.net.*;
    public class Conn2 {
        private PrintWriter out;
        private BufferedReader in;
        private Socket socket;
        public Conn2()
            try {
             socket = new Socket("www.google.at", 80);
             out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));         
             if (out.checkError())
              System.out.println("SSLSocketClient:  java.io.PrintWriter error");
             in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                System.out.println("Connect erfolgreich.");
         } catch (Exception e) {
             System.err.println(e);
        public void test()
            String inputLine;
            // 1. GET
            out.println("GET / HTTP/1.0");
         out.println();
         out.flush();
         try
                while ((inputLine = in.readLine()) != null)
                    System.out.println(inputLine);
            catch(IOException e)
                System.err.println(e);
            // 2. GET
            out.println("GET / HTTP/1.0");
         out.println();
         out.flush();
            try
                while ((inputLine = in.readLine()) != null)
                    System.out.println(inputLine);
            catch(IOException e)
                System.err.println(e);
    }

    Normally in the HTTP protocol, the server will close the connection after every request. So after you do the first GET, the server sends you the result and closes the connection. You have to open a new connection for the second GET.
    You can set specific headers to keep the connection open, which makes things faster if you have to do multiple GET's quickly after another. Lookup the specification of the HTTP protocol on http://www.ietf.org/
    Maybe it's easier to use a HTTP client library like Apache's HTTPClient: http://jakarta.apache.org/commons/httpclient/ so that you don't have to implement all the difficulties of the HTTP protocol yourself.

  • How many instance created for 100 request in servlet?

    Let me know the answer

    STM12 wrote:
    Subject: how many instance created for 100 request in servlet?
    Let me know the answerInstances of what?

  • Alternatives to loading .properties files for every request

    I am just starting for a company, and they loading a bunch of .properties files for every request. I've told them that according to JEE specs, using the file system like that is a violation, as it's not scalable. I've suggested the following alternatives:
    1. Load a file once, in a static initializer, or something to that effect. Re-start the app if a change needs to be made in properties.
    +: few changes
    -: requires a new war/ear to make a change
    2. Put properties that are truly variable in a database record.
    -: requires DB schema change.
    3. For instance, i've though about using something like jconsole to change an mbean property, and then web apps using that property.
    4. Define a single web app that exposes an EJB/JMS/RMI object which serves properties to other web apps. If a change is needed, only 1 web app needs to be re-started, although it would still have to be re-packaged. Perhaps this app could load this stuff from the DB.
    5. Have a properties service, and expose it as an RMI object. If a change needs to be made on the fly, use rmi to make the updates.
    I'm leaning towards a combination of 1, 5, and possibly 4.
    I would like to know what other alternatives might be available.
    Thanks.

    I am just starting for a company, and they loading a
    bunch of .properties files for every request. I've
    told them that according to JEE specs, using the file
    system like that is a violation, as it's not
    scalable. well, it's just boneheaded that's all
    I've suggested the following alternatives:
    1. Load a file once, in a static initializer, or
    something to that effect. Re-start the app if a
    change needs to be made in properties.that's what most people do
    2. Put properties that are truly variable in a
    database record.well, databases don't normally hold config info, but you can do what you want
    -: requires DB schema change.
    3. For instance, i've though about using something
    like jconsole to change an mbean property, and then
    web apps using that property.
    4. Define a single web app that exposes an
    EJB/JMS/RMI object which serves properties to other
    web apps. If a change is needed, only 1 web app needs
    to be re-started, although it would still have to be
    re-packaged. Perhaps this app could load this stuff
    from the DB.doing EJB or RMI for getting properties sounds like overkill in the extreme to me

  • Client handler is invoking for every request.

    Hi EveryOne
    i am new to JAXWS welogic.
    i have a web consumer/client, while sending the request from client the handler is invoking for every request. I could not able to restrict.
    i would like to intialize only once and need to use that instance like (init() method initialization). How to resolve this issue.
    can anyone come across a solution for JAX-WS in general? Please throw your thoughts here.
    Any help in this regard would be appreciated.
    Thanks & Regards
    Suresh

    Two common reasons for this are:
    (1) Problem with the system clock: date, time, or time zone differs substantially from the rest of the internet
    (2) Firefox not set up to work with your security software that filters your web traffic
    In order to filter secure traffic, your security software needs to present "fake" certificates to Firefox so it can be the "man in the middle" and see everything sent to and from the site. Firefox distrusts the fake certificates until instructed otherwise.
    Do you use any software with that kind of feature? On Windows, products with that feature include avast! 2015, Bitdefender, ESET, and Kaspersky.
    A less common problem is malware performing a "man in the middle" attack.

  • "A new folder for every project file"

    Aha!!  Right, from now on ... (thanks Steve)
    From the Muvipix.com Guide to Adobe PE11 by Steve Grisetti
    (p 36) [on starting and saving a new project]
    2     Click the Browse button to choose a location to save your new
    project file.
    We at Muvipix recommend always selecting the Browse option and,
    wherever you choose to save your file, creating a new folder for every
    new project file.
    This little bit of housekeeping keeps all of your new project's files in
    one neat, little folder. And, when your project is done and you want to
    clear it from your computer, you can then remove not only the project
    file but all of the temp, render and scratch disk files Premiere Elements
    has created for that project simply by deleting that single folder!
    This makes post-project clean-up a much easier and neater process.
    OK, hope I've got it this time (at last)
    cheers
    Brian

    Oh no!  I thought I’ll re-work that Canal video again, but this time saved the project from the very start in a new folder on an ext HD (500 GB) connected USB3.0.  Tried all sorts of things on it, saved each time in the same folder.   Cleared all 14 clips from Project Assets (which of course emptied the timeline).   Shut down PE11.   Checked via Windows Explorer that the project files were all on the ext HD – and by the way, there are no other files on it, just the PE files.  My understanding is that Advanced System Care Pro (Iobit) regularly defrags all my drives if necessary (tho’ I haven’t done this manually for months with this drive).
    OK, opened PE, went to Open Recent Projects, it shows the above .prel file and the entire path, I click on it and – 
    Weird, just weird
    Nil desperandum
    Brian
    Edited --- and another weird thing, my email isn't sending the complete message I type to this forum.   I sent a whole message once and it never appeared, but this time it's cut off half a sentence above (it did this before, earlier today).
    That sentence should read,
    OK, opened PE, went to Open Recent Projects, it shows the above .prel file and the entire path, I click on it and – nothing happened!   (You'll have gathered that's what happened, but I wrote it in my Windows Live Mail, sent via BT-Yahoo ISP ......... )  Hey wait, there was a whole lot more.
    Here's a copy / paste from Windows Live Mail outbox
    It’s so odd, because as I said previously, most of the time it works so well, does all the things it’s supposed to do.   I followed Steve’s instructions here to the letter.   By the way, as you know, it’s not just the ext HD, this has been happening all along with allowing PE to save everything in its default Folder 11.
    I would be – now – very sorry indeed to have to abandon PE11 simply on this account, but it’s causing me to waste such a lot of time.   (Let alone the expense of buying it, plust one Lynda.com course, plus 2 books – not forgetting that I’d previously tried the Corel software and bought a book and DVD for that too!!)
    Might just use – what’s that simplicity-itself thingy everyone uses who just want to get any old kind of thing up on You Tube ..........   Oi vey!! <<more weary sigh>>
    Weird, just weird
    Nil desperandum

  • Specify filter for every request except one

    Can a in me web.xml file specify that a filter should be used for every request except one.
    I can write;
    <filter-mapping>
         <filter-name>MyFilter</filter-name>     
         <url-pattern>/*</url-pattern>
    </filter-mapping>
    to use it on every request. But how do I exclude one specific resource that shouldn't go though the filter.
    I know that this may not be exactly the right forum but i'm really lost. I appreciate all suggestion.
    Thanks / Daniel

    This is the right forum, but unforutanetly you cannot exclude some urls.
    I would suggest you handle that logic in the filter itself.

  • Notes in Mail: Every time I type a new note it is emailed to my Mail along with a new note for every change I make to it

    Notes in Mail: Every time I type a new note it is emailed to my Mail along with a new note for every change I make to it.
    I don't mind the Note being updated in my mail but I don't need a new copy every time I edit/add to the note.
    It's driving me mad!
    Thanks.

    A new tab opens by default as a blank tab (about:blank).
    If that isn't the case then an extension has changed that behavior.
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Is lookup required for every request(SLSB)?

    Hi,
    I have a SLSB and a client that makes frequent requests as needed. The question is, should the client make a fresh lookup for every request in a session or just once per session?
    I have tried both the ways and got it to work...but can someone tell me the correct approach for lookup?
    thanks in advance.

    Thanks for the reply!
    By your statment that EJB Home Handle can be cached, I understand the following..
    MyBeanRemote mybean = null; // declaring as class variable.
    // making a request
    if(mybean==null)
    lookupBean();
    mybean.doSomething();
    // making next request
    if(mybean==null)
    lookupBean();
    mybean.doSomethingMore();
    // here goes the lookup...
    lookupbean() {
       mybean = ...lookup("......");
    }so, this is how before each request, I check if the mybean is null. in lookupBean(), the bean-lookup process is executed and reference is set to mybean.
    am I right?

  • Servlet 2.3 - Filters for every request to the WebContainer

    I want to filter every request to the web container. How do I deploy the filter without confining it to a particular context? For example, I would want to filter everything that went to www.bea.com. But if I deploy it as a webapp, it will only filter from www.bea.com/mywebapp. So I lose any request that go to www.bea.com/anothercontext. I have tried mapping the filter to the FileServlet, but once again, it only works inside of the context of the webapp.
              Is there a way to map the Filter to the docroot of the server?
              I am using Weblogic 6.1 and am currently deploying every thing as a .war file
              

    yep - thats my understanding
              I dont know of a way to deploy a single filter at the server level that
              covers all webapps. I'm not saying there isnt a way - I don't know of one
              Anyone out there know for sure?
              "Chip Sands" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Please correct me if I am wrong, but that would mean that I would have to
              deploy
              > my filter into every webapp on the server because "/" is relative to the
              context.
              >
              > Unfortunately, that is not an option for me. I do not have knowledge of
              the other
              > webapps deployed on the server, but am required to have all requests to
              those
              > contexts go through my filter.
              > I was hoping there was a way to deploy a filter outside of a webapp and
              stick
              > it at the docroot of the server.
              >
              > Chip
              > "Matt Krevs" <[email protected]> wrote:
              > >I'm not sure you can do this
              > >
              > >The only way I can think of is to deploy your filter in all of your web
              > >apps
              > >and map it against the root context of each web app
              > >
              > >What happens if you deploy the filter within the default web app that
              > >has a
              > >context of "/" ?
              > >
              > >"Chip Sands" <[email protected]> wrote in message
              > >news:[email protected]...
              > >> I want to filter every request to the web container. How do I deploy
              > >the
              > >filter without confining it to a particular context? For example, I
              > >would
              > >want to filter everything that went to www.bea.com. But if I deploy
              > >it as a
              > >webapp, it will only filter from www.bea.com/mywebapp. So I lose any
              > >request that go to www.bea.com/anothercontext. I have tried mapping
              > >the
              > >filter to the FileServlet, but once again, it only works inside of the
              > >context of the webapp.
              > >> Is there a way to map the Filter to the docroot of the server?
              > >> I am using Weblogic 6.1 and am currently deploying every thing as a
              > >.war
              > >file
              > >
              > >
              >
              

  • Session is set for every request

    Hi,
    With WL Server 6.1SP1 we have some peculiar problem. Every request
    is considered as a new request and a new session object is created. So
    the information we stored in the session is no longer available for
    subsequent requests. This behaviour is seen intermittently. Session is
    not invalidated and session is not timed out.
    Thanks,
    Prasad

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.             
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar                                      

  • Opinion: new Package for every new custom Component?

    Hi there,
    I am just thinking of some possibilities to structurize my Components I made.
    I wonder if it is useful/good programming to define a new package for each new custom Component?
    So if I define a new MyComponent class extending JFrame should I make a new package:
    "mycomponent"
    containing these subfolders:
    "view"
    "model"
    "controler"
    subfolging "controler" in:
    "listeners"
    "adapters"
    "events"
    Is there any sense to do so? I think this would be the best way to structurize one's components.
    But if you do, you have to include millions of packages if you want to use one of these components :(.
    Please post, what you think.
    Thank you
    Sincerely
    Karlheinz Toni

    nope ;). I would most certainly not want to put every file in a single directory.
    But I like sturctured things. If things belong to each other, it should be visible at once, that they have something to to with each other. And the best method I can figure you is putting them in one package.
    The subpackages should be created, because of the model, that is used for all swing componentd (UI-delegete, MVC...) so that each structural component is where it belongs to.
    I don't like it if tere are 100 events one object could possibly create and you don't know the events from the component (of course you can guess by the name Event :)), but if they are in the same package, you would have to scroll a long way to get the thing you want (either m, v or c).
    So this is why I would do it ;).
    Anyway: do includes make the program run slower (I have read many threads about it, but there are way to many opinions, so I would be grateful if you post your opinions here, thx ;).
    Thanks for your answer,
    Sincerely
    Karlheinz Toni
    p.s.: why wouldn't you put them in a seperate directory (just overkill?), would you use classes that are structured like this if you are looking for a implementation of something and find it in this structure?

  • SharePoint 2010 creates a new instance for SharePoint server.

    I have installed SP 2010.My env is Windows server 2008 R2 and SQL 2008 r2 (10.50.1600). When I install the SP 2010,
    configuration wizard (Start the SharePoint Products Configuration Wizard) directly goes to configuration wizard and installed SP 2010 server successfully.
    It skips the below Manual configuration.
    1. Specify Configuration DB settings
    2. Specify Farm Security settings.
    3. Configure CA Web Application settings. etc...
    So I get the new SQL instance with the name <MachineName>\sharepoint.
    This new Instance is looking SQL 2008 version(10.0.2531).
    Now I face the below issues,
    1. When I restore DB backup, i get the compatability issue 
    2. Unable to restore the SP2010 site which is backuped from SQL 2008 r2 (10.50.1600) has 9GB size.
    3. Unable to extend the DB size from 4096 MB. 
    How to avoid create new SQL instance with the name <MachineName>\sharepoint and install in SQL server default <MachineName> instance?
    Loganathan S

    Hi Paul
    stork,
    thanks for the help. Now I have another Two questions. I'm search service application in SP 2010. It works fine when I search data from home sites it works fine.
    1. When I search from within sub-sites i don't get any search results. What mistake I have done here?
    Second question from Restore spsite...
    2. When I restore the site in 80 port, the search service does not crawl and pick the new properties from the restore site. But when I restore the same site in another port<8080/8099/etc>  the search service does crawl and pick the new
    properties from the restore site. Why the service not working in 80 port.?
    Note: I have checked with 3 test env my bak file. but all the 3 env gives same result.... 80 port  does not crawl and pick the new properties.
    Loganathan S

  • Time Lapse import creates new clip for every frame!

    I shot a time lapse film - five hours reduced to 4 minutes ie one frame every 4 seconds. The iMovie Import wizard created a separate 'Clip' for every frame, (which is unusable), and then crashes the program every time I try to open it, I guess because there are too many 'Clips' to handle.
    Is there a way to import these discontinuous shots as a single clip? If iMovie can't do it, any ideas on a better way? I couldn't get Quicktime Pro to do any better - it opened thousands of separate windows on the desktop.
    Fortunately, the original is on DV, though each frame has a different time stamp on it.
    Thanks for any ideas!

    FYI
    I found that iMovie 6 was able to handle the multiple files and I could export them as an MPEG4 file. iMovie 08 bombed big time.

Maybe you are looking for

  • Deploying war file in weblogic SIP server 2.2

    Hi, I trying to deploy a "sar" file in weblogic SIP server,but it is not allowing me to do that.So one of my collegue told me to change the "sar" to "war" and try to deploy. When i am trying to deploy that it is saying that unable to find deployment

  • Filter to fill in area with NOT ALIGNED dots?

    Excuse the caps. It's to prevent this topic to be filled out by forum racers mentioning the halftone filter and allow real answers stand out. Hi, I'm a graphic designer, illustrator user since '89, and I need a filter that would work as the 8-ball fr

  • Movie Lists content not aligning between Apple TV & ITunes

    I have purchased a digital copy of a  particular film and so after also purchasing an Apple TV I watched it.  However the next time I used Apple TV it didn't appear in my "Purchased  Movies List". Checking the iMac showed that it was still on it's  "

  • How to specify overflow clause for IOT

    Hi, I'm using OSDM v3.0.0.665 How do I specify 'overflow' clause for index organized table (IOT)? I need to generate DDL something similar to this " create table T1(--.) organization index..overflow". In OSDM, when I open physical model and table pro

  • Fit Sinc Function to Data

    Dear community, I recently wrote a program that fits a Gaussian function to some intensity data I pulled from an image of a fluorescent nanoparticle. Here's a snapshot: My program would be a lot more useful if I could fit the data to a Sinc function