Instance of each servlet

I have a web page ,JSP, which calls different servlets for DB stuff. My question is this : will there be a new instance of each servlet for each user when connecting to the the website or should I do something about it.

hello again
could you also tell me whats the correct way to do
this. As far as I know I can mix the Model and
controller inside a servlet, but with this fixture
everything will go nuts! do you think I should use
the servlet as a controller and a javabean as a
model. OR something else.
Thanks again for the help.I was in your situation 1 or 2 years ago, and I would just like to share what I've found and try to explain in an easy manner what technologies you could use, and how they work.
The problem with servlets is that each connection to the same servlet will create a new thread. This is different from the classical CGI approach, where each connection starts a new process.
The consequence is that you end up coding in a multithreaded environment, with all the hassles with deadlocks, race conditions, problems with shared variables (as mentioned in previous posts) etc.. These problems are difficult to solve, and time consuming. The reason for the multithreaded solution is that it provides a significant performance boost over the "new process" solution. However, it is obvious that a developer doesn't want to worry about multithreading when he/she has a deadline to comply with ;) So, you ask, should I just scrap Servlets or is there a better solution?
Well, to get rid of this problem for developers, Sun proposed a standard to reduce the complexity of web development. It's called Java EE (http://java.sun.com/javaee/5/docs/tutorial/doc/)
By maintaining persistent (long lasting) state in a database, and temporary state (session state etc) in a controlled manner, Java EE proposed a way of getting rid of the classical problems in Java web development, and also added several cool new features.
When using Java EE, you have a special type of beans to save persistent state, they're called entity beans. If you have defined a entity bean (wrote an ordinary java class, and supplied some settings), you can create a new entity bean, set its properties, and tell the Java EE system to save it to your database. You can also search among saved ones (something like "select p from Person as p where p.username='foo' and p.cousin.name='bar'"), let them reference each other and all sorts of neat things.
There are also beans which are supposed to perform logic using your entity beans, and they're called session beans. They have methods containing your business logic, namely methods like 'getLatestForumPost(), or 'createUser(String name)'...
The session beans can also save temporary state. If they do so, they're called "stateful session beans". The state they keep is stored like ordinary class attributes, but Java EE makes sure that you won't get thread problems (even though there still are multiple threads). For example, you can use this state to keep track of items in a shopping cart (based on the current user). If several users want their own cart, Java EE just creates a new stateful session bean for each user, you don't have to modify your bean in any way!
Until now, I've used the word "Java EE", as if it's an actual product, but as I mentioned, it's just a standard. Since it is just a standard, telling how things should work, there are several companies that have made solutions (programs) that actually make things work like this. An application that "make thing work" is called a Java EE Application Server. You need to start the application server in order to run you own Java EE program (you program will be almost like a plugin to the server, or you could say that you program runs within the server). Behind the scenes, the application server usually uses ordinary Servlets to process each request, but it handles all the multithread problems (and others) for you. If you for some reason would like to, you can always gain finer control by using Servlets directly.
When a user connects to your computer, the server can automaticly identify the user, give him some cookies identifying him, ask for login (if you told the server to do so), and then hand over control to you, telling you this persons login name, what he asked to do, amongst other things, which saves you a lot of hassle. You can alway tell the server how to behave in different situations (for example wich pages or requests that require login etc), by writing some xml config files for each application.
The application server also lets you send mails from your session beans, send messages between computers, run your application on clusters, parse XML and several of other neat things. It's a dream for a web application developer.
I hope this will inspire you to have a look at these things, because it really simplifies things, and if you learn it correctly, you can also make some serious money as a Java EE developer ;)
The only downside is that it seems pretty complex in the beginning, and that it's pretty hard to understand all the vague definitions in the docs etc... I would recommend that you download the Application server from Sun (http://www.sun.com/software/products/appsrvr/index.xml), read the tutorial at http://java.sun.com/javaee/5/docs/tutorial/doc/ and start to write some own programs.
Don't be passive, just try everything out and you'll figure out that it's less complicated than it seems at the first glance.
I really hope that this helps!, and sorry for my bad English.
Best regards
/Alexander T

Similar Messages

  • Running multiple instances of same servlet

    I am trying to run multiple webapps off of the same weblogic5.1 instance.
              I have setup the webapps and they work individually, but I need one servlet
              to load at startup.
              I have only been able to do that by including it by name in
              weblogic.properties
              #webApp named
              weblogic.httpd.webApp.demand=d:/stat_forecast/
              #register servlet so it runs on startup
              weblogic.httpd.register.AppInitServlet=com.ai.servlets.AppInitServlet
              weblogic.httpd.initArgs.AppInitServlet=AppConfigFilename=d:/stat_forecast/pr
              operties/forecast.properties
              weblogic.system.startupClass.aiservlet=weblogic.servlet.utils.ServletStartup
              weblogic.system.startupArgs.aiservlet=servlet=AppInitServlet
              This works until I try to add another instance of AppInitServlet for a
              different webApp
              #webApp named
              weblogic.httpd.webApp.supply=d:/supply/
              #register servlet so it runs on startup
              weblogic.httpd.register.AppInitServletS=com.ai.servlets.AppInitServlet
              weblogic.httpd.initArgs.AppInitServletS=AppConfigFilename=d:/supply/supply.p
              roperties
              weblogic.system.startupClass.aiservletS=weblogic.servlet.utils.ServletStartu
              p
              weblogic.system.startupArgs.aiservletS=servlet=AppInitServletS
              The servlet does not run a second time.
              Is there a way to move the AppInitservlet to inside the webApp and maybe use
              the web.xml to start each one individually?
              Thank you for any insight
              John Norton
              Indent Inc
              John Norton
              Indent Inc.
              (Innovative decision technologies, inc.)
              [email protected]
              

    Replying to myself to try and clarify.
              We are trying to run 2 or more webapps, each webapp tryes to call the
              servlet AppInitServlet.
              The servlet will not allow more than one instance to be in a context.
              In tomcat the servlet works to give a separate instance for each app.
              "JohnNorton" <[email protected]> wrote in message
              news:[email protected]...
              > I have sp8 on one version and that does work for the load on startup. One
              > problem solved, thank you.
              > Second part of same problem
              > In tomcat where we were developing, we could have multiple instances
              of
              > the AppInitservlet (for different Apps) and it kept them all separate.
              > In WL51 it starts the first correctly, but does not keep them
              separate,
              > so the second instance does not happen. It is designed so that
              multiple
              > calls do not instantiate (this would normally be within one instance of
              one
              > App).
              > I had thought that if the servlet was load-on-startup from the webApp
              > web.xml file that they would be separate. Any more ideas or clues?
              >
              > Thank you
              >
              > John Norton
              >
              > "Dimitri Rakitine" <[email protected]> wrote in message
              > news:[email protected]...
              > > Try it with the latest service pack - load-on-startup in web.xml was not
              > > supported until sp8 or so.
              > >
              > > JohnNorton <[email protected]> wrote:
              > > > I am trying to run multiple webapps off of the same weblogic5.1
              > instance.
              > > > I have setup the webapps and they work individually, but I need one
              > servlet
              > > > to load at startup.
              > > > I have only been able to do that by including it by name in
              > > > weblogic.properties
              > >
              > > > --------------
              > > > #webApp named
              > > > weblogic.httpd.webApp.demand=d:/stat_forecast/
              > >
              > > > #register servlet so it runs on startup
              > > > weblogic.httpd.register.AppInitServlet=com.ai.servlets.AppInitServlet
              > > >
              >
              weblogic.httpd.initArgs.AppInitServlet=AppConfigFilename=d:/stat_forecast/pr
              > > > operties/forecast.properties
              > > >
              >
              weblogic.system.startupClass.aiservlet=weblogic.servlet.utils.ServletStartup
              > > > weblogic.system.startupArgs.aiservlet=servlet=AppInitServlet
              > > > ---------------
              > > > This works until I try to add another instance of AppInitServlet for a
              > > > different webApp
              > > > #webApp named
              > > > weblogic.httpd.webApp.supply=d:/supply/
              > >
              > > > #register servlet so it runs on startup
              > > > weblogic.httpd.register.AppInitServletS=com.ai.servlets.AppInitServlet
              > > >
              >
              weblogic.httpd.initArgs.AppInitServletS=AppConfigFilename=d:/supply/supply.p
              > > > roperties
              > > >
              >
              weblogic.system.startupClass.aiservletS=weblogic.servlet.utils.ServletStartu
              > > > p
              > > > weblogic.system.startupArgs.aiservletS=servlet=AppInitServletS
              > >
              > >
              > > > The servlet does not run a second time.
              > > > Is there a way to move the AppInitservlet to inside the webApp and
              maybe
              > use
              > > > the web.xml to start each one individually?
              > > > Thank you for any insight
              > >
              > > > John Norton
              > > > Indent Inc
              > > > --
              > > > *************************************************
              > > > John Norton
              > > > Indent Inc.
              > > > (Innovative decision technologies, inc.)
              > > > [email protected]
              > >
              > > > *************************************************
              > >
              > >
              > >
              > >
              > > --
              > > Dimitri
              >
              >
              >
              

  • Instance variables in Servlets.

    Hi
    Is it a good practice to use instance variable in servlet.
    Please refer code snippet below.
    public class ExcelAction extends HttpServlet {
    private int var1 =0;
    doGet () {
    var1++;
    fun1();
    fun1 (){
    var1++;
    }Like in above code I have used an instance variable var1 because I wish the same to be accessible in all servlet functions.
    I guess it is not a good practice, as different requests to this servlet at same time will result in multiple threads of this servlet. Which will make the state of var1 unsafe.
    If this is correct then what are the alternates if I wish to share variables between functions in a servlet.
    Thanks

    money321 wrote:
    Because in beginning I was not sure that Servlets instances are also actually threads.They are not not threads. Each call to doGet(), doPost() etc is called in a Thread and since there can be many simultaneous calls each having it's own thread a Servlet has to be thread safe.
    My other question was specific to threads as I was trying to implement threads.Why?
    >
    But in this one I rather used servlets.
    But apologies, as instance of servlet are also threads.As I said, they are not threads.
    >
    But still one last doubt.
    Sabre if you could please clarify the same as well :How about you do some reading [http://java.sun.com/developer/onlineTraining/Servlets/Fundamentals/|http://java.sun.com/developer/onlineTraining/Servlets/Fundamentals/] and use Google.
    >
    in your option 2 and three I will have to pass request object to function fun().No. You will need access to the request object for 2 and the servlet context for 3. You need to pass something
    If i am correct on this then is this too a better approach ?My preferred approach is 1 since it makes much of your code testable outside of a Servlet.

  • Is each servlet created in a separate JVM

    Hi,
    I am wondering if each servlet runs in a separate JVM?
    Does this depend on the servlet container we use?
    Thanks guys

    No. One server runs in one JVM.
    All servlets run by that server run in the same JVM.
    You can have multiple instances of the server running of course, each would be in its own JVM and require its own resources.

  • Scope of instance variables in servlets..

    Hi all,
              Sorry for asking a dumb question..
              What is the scope of instance variables in a servlet? Is the scope is
              limited to thread?
              In other words, in the following example, i am setting "testStr", in one
              request and when i tried to access the same instance variable from another
              request, i am getting it as null. Does it mean instance variable is limited
              to that particular thread/request?
              thanks in advance..
              -ramu
              

    Oops ... I had misunderstood and had the problem backwards ;-)
              > Is it known behavior? With registered servlet its working fine (a
              > instance variable is shared by all requests)
              I believe so; I typically deploy in a WAR so have not seen the problem that
              you describe. Servlets can be reloaded, so what you saw could have been
              caused bye a date/time mismatch between the .class file and the server's
              current time. On the other hand, that could be how WebLogic works.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Ramu" <[email protected]> wrote in message
              news:[email protected]...
              > Hi Purdy,
              >
              > I got it. I am testing the servlet as a unregistered servlet, which is
              > creating instance for every new request!!!, which created this whole
              > confusion. Is it known behavior? With registered servlet its working fine
              (a
              > instance variable is shared by all requests)
              >
              > > What theory? ;-) Instance variables are on the object, and the object
              can
              > > be used by multiple threads, thus allowing multiple threads to access
              the
              > > same instance variables.
              > what i mean by theory here is, all instance variables in servlet should
              be
              > shared by all requests. Now i got it sir.
              >
              > Thank you..
              > -ramu
              >
              >
              > >
              > > Peace,
              > >
              > > --
              > > Cameron Purdy
              > > Tangosol, Inc.
              > > http://www.tangosol.com
              > > +1.617.623.5782
              > > WebLogic Consulting Available
              > >
              > >
              > > "Ramu" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Hi,
              > > >
              > > > > No, an instance variable in a servlet class is not limited to a
              > thread.
              > > > There
              > > > > is exactly one copy of the servlet created in memory and all
              requests
              > > pass
              > > > > through the same instance, thus sharing any instance variables. A
              > > couple
              > > > of
              > > > > things to remember:
              > > > I totally agree with you, But i am wondering why my sample servlet(i
              am
              > > > attaching the file) is not sharing the instance variables across
              > > > threads/reqs. (in 1st request set some string to "testStr" instance
              > > > variable, in next request if you read the same instance variable, you
              > will
              > > > get null!!)
              > > > Our current code is having instance variables. But right now we are
              not
              > > > getting any problems. But as per theory, instance variables should be
              > > shared
              > > > across threads/requests..
              > > >
              > > > Any how we are changing our code to remove all instance variables.
              > > >
              > > > thanks,
              > > > -ramu
              > > >
              > > > >
              > > > > 1.) Using instance or class variables in servlets that are not
              > read-only
              > > > is not
              > > > > a good thing to do. This makes the servlet not thread-safe. To
              > > maintain
              > > > > variables across requests, sessions, etc., use the servlet-defined
              > > objects
              > > > to
              > > > > store the state (e.g., request, session, etc.).
              > > > >
              > > > > 2.) If you modify the servlet class on disk, WebLogic will reload
              the
              > > > servlet
              > > > > class thus discarding the old instance and creating a new one (of
              > > course,
              > > > this
              > > > > depends on some configuration parameters for servlet reloading).
              > > > >
              > > > > Hope this helps,
              > > > > Robert
              > > > >
              > > > > Ramu wrote:
              > > > >
              > > > > > Hi,
              > > > > > thanks for quick reply.
              > > > > > I am not at all using SingleThreadModel. See the following code.
              > > > > > In first request i am passing "abc" value to testStr. But in
              second
              > > > request,
              > > > > > I am getting null for testStr in second request. It looks like
              (for
              > > me)
              > > > for
              > > > > > non single threaded model also, scope of instance variables is
              > > limited
              > > > to
              > > > > > Thread/Request.. But as per theory, because its not single
              threaded
              > > > model,
              > > > > > only one instance should be there AND testStr(instace variables)
              > > should
              > > > be
              > > > > > shared across the all threads. But i am not able see that
              behaviour
              > > > here.
              > > > > > But if declare instance variable as static, o am able to share
              it
              > > > across
              > > > > > all threads/requests.
              > > > > >
              > > > > > note:
              > > > > > From browser i am setting testStr to "abc" with URL like
              > > > > > "localhost/test1?testStr=abc"
              > > > > > And 2nd req from browser is like "localhost/test1" (on server
              > output
              > > i
              > > > am
              > > > > > getting null for testStr)
              > > > > >
              > > > > > Any ideas?
              > > > > >
              > > > > > thanks,
              > > > > > -ravi
              > > > > >
              > > > > > import java.io.*;
              > > > > > import javax.servlet.*;
              > > > > > import javax.servlet.http.*;
              > > > > >
              > > > > > public class test1 extends HttpServlet
              > > > > > {
              > > > > > public String testStr;
              > > > > >
              > > > > > public void doGet (HttpServletRequest req, HttpServletResponse
              res)
              > > > > > throws ServletException, IOException
              > > > > > {
              > > > > > doPost(req, res);
              > > > > > }
              > > > > >
              > > > > > public void doPost (HttpServletRequest req,
              HttpServletResponse
              > > res)
              > > > > > throws ServletException, IOException
              > > > > > {
              > > > > > try {
              > > > > > res.setContentType("text/html");
              > > > > > PrintWriter out = res.getWriter();
              > > > > > if(req.getParameter("testStr") != null)
              > > > > > {
              > > > > > testStr = req.getParameter("testStr");
              > > > > > System.out.println("set testStr = " + testStr);
              > > > > > }
              > > > > > else{
              > > > > > System.out.println("get testStr = " + testStr);
              > > > > > }
              > > > > >
              > > > > > }
              > > > > > catch(Exception e){
              > > > > > e.printStackTrace();
              > > > > > }
              > > > > >
              > > > > > }
              > > > > > }
              > > > > >
              > > > > > "Cameron Purdy" <[email protected]> wrote in message
              > > > > > news:[email protected]...
              > > > > > > Yes or no, depending on if your servlet implements
              > > SingleThreadModel.
              > > > > > >
              > > > > > > See the servlet 2.2 spec for documentation on how many instances
              > of
              > > a
              > > > > > > servlet will be created. See the doc for the SingleThreadModel
              > > > interface.
              > > > > > >
              > > > > > > Peace,
              > > > > > >
              > > > > > > --
              > > > > > > Cameron Purdy
              > > > > > > Tangosol, Inc.
              > > > > > > http://www.tangosol.com
              > > > > > > +1.617.623.5782
              > > > > > > WebLogic Consulting Available
              > > > > > >
              > > > > > >
              > > > > > > "Ramu" <[email protected]> wrote in message
              > > > > > > news:[email protected]...
              > > > > > > > Hi all,
              > > > > > > >
              > > > > > > > Sorry for asking a dumb question..
              > > > > > > >
              > > > > > > > What is the scope of instance variables in a servlet? Is the
              > scope
              > > > is
              > > > > > > > limited to thread?
              > > > > > > >
              > > > > > > > In other words, in the following example, i am setting
              > "testStr",
              > > in
              > > > one
              > > > > > > > request and when i tried to access the same instance variable
              > from
              > > > > > another
              > > > > > > > request, i am getting it as null. Does it mean instance
              variable
              > > is
              > > > > > > limited
              > > > > > > > to that particular thread/request?
              > > > > > > >
              > > > > > > > thanks in advance..
              > > > > > > >
              > > > > > > > -ramu
              > > > > > > >
              > > > > > > >
              > > > > > > >
              > > > > > >
              > > > > > >
              > > > >
              > > >
              > > >
              > > >
              > >
              > >
              >
              >
              

  • Access of Instance variable in servlet

    hi,
    If i declare a instance variable in servlet , can i access that variable throughout my application??.
    please let me know.
    thanks in advance.

    Servlets are Java classes. They follow all the rules of Java.

  • ** Is it possible to create new BPM instance for each record (Multiline)

    Hi friends,
    In my scenario, JDBC adapter (sender) polls the open purchase order items from the table at the specified interval and send to BPM. In BPM, we used transformation step to split the messages to process each PO . The scenario is working fine. The problem is assume that if we process 10 PO, the error is in  4th PO while process, the BPM will be stopped in 4th PO. Once we correct the error, we are able to restart.
    In this case, we are not able to skip the 4th PO and process from 5th PO onwards. ie. the processing is sequential. Instead, we want to start new BPM instance for every PO. Advantage is that if 4th PO is error, only that BPM instance (work item) will be stopped. Remaining 9 POs will be completed.
    So, how do we start new BPM instance for every PO ?
    Kindly tell me, friends.
    Thank you.
    Kind Regards,
    Jeg P.

    Hi,
    There are two ways to achieve this.  In BPM and before BPM.
    Before BPM:
    Use 1 to unbounded mapping and 1 to unbounded interface mapping.
    In your mapping, make sure you create a seperate message for each PO.
    In BPM:
    Create a multiline container with you POs using a 1 to n mapping.
    Now add a ForEach block to loop through the multiline container and send each PO.
    Important:  Add an exception branch to catch any exception for each send so that the exception does not make the BPM fail.
    Regards,
    Yaghya

  • Extra characters at the end of each servlet response

    I am attempting to develop a servlet that sits between a server and a browser, and simply martials arguments to send to the server, and then forwards responses to the web browser. When working with Weblogic 5.1 sp 11, things worked fine, except that an extra new line was added to the end of each response. I am now testing against Weblogic 7.0, and instead of a new line the characters "null" (not including the quotes) are added. I have tried to experiment to see if anything I have written or control is causing these characters to be sent to the client, but as far as I can tell there is nothing there. The I write my final character, close the ouput stream, and the client recieves bytes I did not send. Has anyone else experienced this? Anyone have ideas on how to fix this problem. Thanks for any input,
              Nathan
              

    Yes! There are advantages with jar files.
    The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, jar was designed mainly to facilitate the packaging of java applets or applications into a single archive. When the components of an applet or application (.class files, images and sounds) are combined into a single archive, they may be downloaded by a java agent (like a browser) in a single HTTP transaction, rather than requiring a new connection for each piece. This dramatically improves download times. jar also compresses files and so further improves download time. In addition, it allows individual entries in a file to be signed by the applet author so that their origin can be authenticated. The syntax for the jar tool is almost identical to the syntax for the tar command. A jar archive can be use as a class path entry, whether it is compressed or not.
    If u require more help on jar file, you can go to the Java Tutorial available on java.sun.com

  • SQL 2012 AlwaysOn Dual Data Centre (an instance in each data centre with a secondary in each other respectively)

    Hi, hopefully someone will be able to find my scenario interesting enough to comment on!
    We have two instances of SQL, for this example I will call them 'L' and 'J'. We also have two data-centres, for this example I will call them 'D1' and 'D2'. We are attempting to create a new solution and our hardware budget is rather large. The directive
    from the company is that they want to be able to run either instance from either data centre. Preferably the primary for each will be seperated, so for example:
    Instance 'L' will sit in data centre 'D1' with the ability to move to 'D2', and...
    Instance 'J' will sit in data centre 'D2' with the ability to move to 'D1' on request.
    My initial idea was to create a 6-node cluster - 3-nodes in each data centre. Let's name these D1-1, D1-2, D1-3 and D2-1, D2-2, D2-3 to signify which data centre they sit in.
    'L' could then sit on (for example) D1-1, with the option to move to D1-2 (synchronously), D2-1,D2-2 (a-synchronously)
    'J' could sit on D2-3, with D2-2 as a synchronous secondary and D1-3,D1-2 as the asynchronous secondaries.
    Our asynchronous secondaries in this solution are our full DR options, our synchronous secondaries are our DR option without moving to another data centre site. The synchronous secondaries will be set up as automatic fail-over partners.
    In theory, that may seen like a good approach. But when I took it to the proof of concept stage, we had issues with quorum...
    Because there are three nodes at each side of the fence (3 in each data centre), then neither side has the 'majority' (the number of votes required to take control of the cluster). To get around this, we used WSFC with Node and File Share majority - with
    the file share sitting in the D1 data centre. Now the D1 data centre has 4 votes in total, and D2 only has 3.
    This is a great setup if one of our data centres was defined as the 'primary', but the business requirement is to have two primary data centres, with the ability to fail over to one another.
    In the proof of concept, i tested the theory by building the example solution and dropping the connection which divides the two data centres. It caused the data centre with the file share to stay online (as it had the majority), but the other data centre
    lost it's availability group listeners. SQL Server stayed online, just not via the AG listener's name - i.e. we could connect to them via their hostnames, rather than the shared 'virtual' name.
    So I guess really I'm wondering, did anyone else have any experience of this type of setup? or any adjustments that can be made to the example solution, or the quorum settings in order to provide a nice outcome?

    So if all nodes lost connectivity to the fileshare it means that there are a total number of 6 votes visible to each node now. Think of people holding up their hands and each one can see the hand. If the second link between the two sites went down then each
    node on each side would only see 3 hands being held up. Since Quorum maximum votes =7, the majority needed to be seen by a node would be 4. So in that scenario, every node would realize it had lost majority and would offline from the cluster.
    Remember that quorum maximum (and therefore majority), never changes *unless* YOU change node weight. Failures just mean then is one less vote that can be cast, but the required majority remains the same.
    Thanks for the complement btw -very kind! I am presuming by your tag that you might be based in the UK. If so and you are ever nearby, make sure you drop by and say hello! I'll be talking at the
    London SQL UG two weeks from today if you are around.
    Regards,
    Mark Broadbent.
    Contact me through (twitter|blog|SQLCloud)
    Please click "Propose As Answer" if a post solves your problem
    or "Vote As Helpful" if a post has been useful to you
    Come and see me at the
    PASS Summit 2012

  • Number of instances of SingleThreaded servlet

    Does anybody know how many instances of a SingleThreaded servlet does WL
              server create per request? Does it do it in say pool of 5 and then if all 5
              are used and a new request comes - does it create another 5 (or so many)? I
              could't find info on this in WL doc.
              Thanks,
              Natasha
              

    Here is my understanding:
              The pool is incremental one by one when all instances of the pool are used.
              Say, if all 5 are used and a new request comes, WL will create a new
              instance for this request, and return this instance to pool later, the size
              of the pool is 6 at this time.
              Cheers - Wei
              Natasha Stavisky <[email protected]> wrote in message
              news:[email protected]..
              > Does anybody know how many instances of a SingleThreaded servlet does WL
              > server create per request? Does it do it in say pool of 5 and then if all
              5
              > are used and a new request comes - does it create another 5 (or so many)?
              I
              > could't find info on this in WL doc.
              >
              > Thanks,
              > Natasha
              >
              >
              

  • Dynamic Pie Chart: Counting the number of instances for each value

    Hello my name is Tim and I am at a roadblock concerning a chart for a dashboard design.
    I have a list with two fields:
    Platform and Status. The list is customized in InfoPath. The
    Platform field is located on the form as a drop-down menu with 6 entries.
    Status is a choice field with 3 selection that is updated through the lifespan of the project (once item created, it is updated to "In process", once the project is closed, the field is updated to "closed."
    My hurdle is viewing these dynamically in a Pie Chart. I am  trying to display the number of project's "In process" for each Platform. So, if Platform A has 6 projects "In process" and Platform B has 3 projects "In process"
    how can this be displayed in a pie chart?
    At the moment, I figured there are two options: Chart View WebPart or importing an Excel  worksheet.
    Any ideas or solution on how to accomplish this?
    -Tim Dempsey

    Three options:
    1. Create a list that holds your statuses. Then in your original list, create a lookup to the status list. In your status list, make a lookup to the lookup. This creates a circular reference which, for whatever reason, returns a count. You can then connect
    a chart web part to this. Repeat for the other column.
    2. Go to your sharepoint list and export to spreadsheet. Save the file. This is a query file that you can use as a data connection. From that file, set it to auto-update and then create a chart from a pivot table. Then use Excel Services Web Part to display
    the file.
    3. The other option is to use Google Charts API. Connect to the list, run some jQuery and JavaScript and then export out a chart. Pretty cool tool.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • Where's the portlet instance for each user?!? (delete a portlet)

    Hi!
    I'd like to know if there's a place (in WeblogicConsole or PortalAdministration or..) where i can see portlets available for a specific user.
    Why? Because, if a user permanently delete a portlet (With the delete button on the portlet title bar) by mistake, I want to give it back to him...
    Any idea how to do this?
    I'm using weblogic 8.1 sp1.
    Thx!
    Dom

    You should be able to add portlets to user through the portal admin tool, if I remeber:
    In nav bar
    Portal Resources
    Portals
    MyPortal
    MyDesktop
    On the right:
    Start playing around with the look and feel
    If you don't have any luck adding the portlet back to the users view try removing the portlet entirely and added it back (bit of a hack but might work)

  • LDAP Context Initialization Problem in a Servlet's Init method

    Hi
    I have a servlet where I am using the InitialDirContext to Initialize context to a LDAP Server. I have created the context as a static variable. I am initializing the context in the init method and am using the same reference in the service method of the servlet. But if the context fails (due to naming exception and time out) in the init method all my requests in the service method will fail. Is there any way to validate the reference before using the same in the service method.
    Also what is the best approach to initialize the context in a servlet. Whether to initialize in the service method or the init method.
    I would appreciate if anyone can answer the above 2 queries.
    Thanks in advace,
    Ashish

    If you want to use threadsafe objects in doPost/doGet there are two common ways to do this.
    First, create the object in doPost/doGet. This may get expensive depending on the object, but it is 'easy' code and works.
    The second option is to create a pool of objects in the servlet's init() method and to just have doPost/doGet get an object from the pool, use it and return it when done. This take a little more work to code, but the overhead of creating objects is almost eliminated. Look at jakarta/apache commons pool for a quick way to do this.
    If you create on object in init() and use it in doPost/doGet, any time you get two request for the same servlet at the same time you will have synchronization issues that will usually cause problems. There is one instance of each Servlet, so all request for that servlet go through the single instance. Anything in doPost/doGet must be threadsafe.

  • How to share objects between two ADF Faces servlet sessions

    I gather the application scope is one way to go for sharing data between sessions in an ADF application. Are there other more generic methods of sharing data between servlet sessions?
    For example, let's say we have a JDev 101.3 ADFBC/JSF app. (or JDev 11g for that matter). In this app we also register a servlet in web.xml. So two people log into this application and access this defined servlet, creating two instances of that servlet...I guess. Is there a way for those two instances/sessions to talk to each other? Pass data back and forth? Should I read about JMS? Or does application scope sound better? I guess a direct communication would be more tidy, than putting data on an application bulletin board, lilke application scope.
    Any thoughts?

    Hi,
    Only one instance of each servlet defined in web.xml gets created, not one per user. You're right about the sessions though, one per user is created. You're right on the other parts as well I think you could use application scope to do something like that, or the data base for that matter, depending on the use case.
    Regards,
    ~ Simon

  • Basic questions about Tomcat

    Hi all, I'm new to Tomcat and I have a few questions...
    1) I have a HttpServlet class in my server. Will an instance of this class be created for each request?. For performance reasons, can I specify a number of instances to be pre-created before user requests? (creating them at user request may be too slow)
    2) I'd like to know more about threads in Servlet Containers. If my HttoServlet class has an instance of a class, will the attributes of this class be thread-safe? How does this work?
    thank you in advance

    1) I have a HttpServlet class in my server. Will an
    instance of this class be created for each request?.No. There is one instance of each servlet object.
    For performance reasons, can I specify a number of
    instances to be pre-created before user requests?
    (creating them at user request may be too slow)On my laptop creating a simple object takes 0.00000001 seconds. Object creation is fast in Java; don't worry about it (unless you really are trying to create a hundred million objects per second and profiling shows that's the bottleneck in your application.)
    2) I'd like to know more about threads in Servlet
    Containers. If my HttoServlet class has an instance
    of a class, will the attributes of this class be
    thread-safe? How does this work?Don't put fields in servlets. Synchronize access to any data that are shared between threads.

Maybe you are looking for