Handling multiple requests

Hi,
I have a servlet which handles a simple process. The retrieved value is put in session and displayed in a jsp. When 2 instances of a same jsp (like in multi user access) pass on the request to this servlet, the retrieval is correct for both instances but the session value is null when redirected to one of the jsps. What could be wrong? Please help.
Thanks!

A session is bound to a client, so it makes no difference if a hundred users call the servlet at the same time, they are all recieving the session variable seperately.
So if the variable at a later point turns up null, there is a bug somewhere in your code, it's as simple as that. Typo in the name when you retrieve the session variable maybe? Perhaps the session is invalidated somehow?
Could be anything really.

Similar Messages

  • How to handle multiple request in the servlet

    how to handle multiple request in the servlet...
    Example:
    java forum...
    i'm login in the java forum at this time 1000 members make login in this....how happended in servlet?
    if we use thread how to implement in servlet ?

    Serlets are already threaded. The application container instantiates the servlet, then uses this instance in a new thread for every use.
    This is the reason that you should use (almost) no instance variables in a Servlet, but rather that (almost) everything should be local to the method.

  • How to handle multiple requests to the same servlet at one time?

    Hi,
    I am new to Servlets. I have doubt regarding ... Handling multiple requests to a servlet at a time.
    If we send a single request to a servlet, as know that group of objects such as servlet, servletContext, servletConfig, request, response and etc are created in the server, And if 1000's of requests are sent to a same servlet at a time, and if server memory capacity is less, then 1000's of objects are created in a server which would be heavy burden to Server. How to handle the application and development in such situation?
    Kind regards,
    veerendra

    Hi veerendra reddy ,
    By default any web server can will have a thread pool to handle client req's.
    In your point also heavy burden to server you are telling that depends on this.
    we can configure this min & max size of this thread pool.
    by default it will be 0-1000 for tomcat server.
    I am not sure in which file this configuration will be.
    But I hope in server.xml or some xml file consists this info.
    If You what you can edit accordingly. to overcome your heavy burden to server.
    Thanks & Regards
    Nagendra

  • How biztalk handle multiple request at a time ?

    can TCP/IP adapter or biztalk handles multiple request at a time ?
    If yes,then how it process multiple request ? 
    Can TCP/IP send ports sends multiple request ?
    Prakash

    Yes.
    It processes multiple requests using THREADS. Each Connect starts off a thread that handles the receipt of the message, submission to BizTalk, wait for the response (matching two-way subscription) and then respond back to the client.
    TCP/IP Send ports handle multiple requests by creating fresh sockets (RPC High-end ports). As an example, in your browser you open multiple tabs and access different sites, each tab results in your browser opening a fresh socket connection for the request.
    Regards.

  • Does a filter instance handle multiple requests?

    A web container creates a thread to handle each request so that a servlet instance handles multiple requests at the sime time. What about a filter instance? Does a filter instance also handles
    multiple requests? or it handles only one at a time

    Here's a quote from the Servlet spec (2.3):
    After deployment of the web application, and before a request causes the container
    to access a web resource, the container must locate the list of filters that must be
    applied to the web resource as described below. The container must ensure that it
    has instantiated a filter of the appropriate class for each filter in the list, and called its
    init(FilterConfig config) method..............
    Only one instance per filter declaration in the deployment descriptor is
    instantiated per Java virtual machine of the container.
    So, if the servlet engine follows the spec, there should only be one instance.

  • Handling Multiple requests in SOAP Sender Adapter

    Hi All,
    We are working on scenario SOAP-IDOC.
    We receive multiple requests from Source, PI should process them and deliver it to SAP system.
    Now the issue is :
    The messages are in separate SOAP requests i.e. 5 messages = 5 SOAP requests.
    If sending a single message there is no issue.
    If sending multiple messages at once then a time-out occurs.(HTTP 408 Timeout) If sending
    5 SOAP requests in the same transmission then the first message will process ok but the other 4 will report an error. If the 5 SOAP requests are transmitted individually then they process ok.
    Can any one throw some pointers on this? What are the settings I have to do in PI so that sender can avoid getting HTTP 408 timeout error?
    Regards,
    Srini

    Hi Srinivasa,
    Set icm/server_port_X parameter . You can change this in RZ10 .Goto tcode RZ10 select the instance profile and select the extended maintenance and click on Change Now click on Create Parameter Tab and write the profile parameter icm/server_port_X and press enter it will show you the default value if any and then put the new value and click on save and F3 and then again save.System needs to be restarted to reflect these changes.
    Also check out the SOAP adapter FAQ on service market place. This would surely solve your problem(time out).
    Rgds
    joel

  • Dynamical Tree handling multiple requests

    Hi,
    I think I already explained well my need. I currently have an
    implementation of a tree control that is dynamic. So, when I click
    to open a node, it sends a request to server to ask for its
    children.
    Attached you have my tree code.
    And here is a sample feedback I have from server in XML:
    <response>
    <status>OK</status>
    <message/>
    <data>
    <item id="3" type="folder" label="Item 1.1"
    isBranch="true"/>
    <item id="4" type="folder" label="Item 1.2"
    isBranch="false"/>
    </data>
    </response>
    The problem is that if I the user clicks too fast to open two
    branches, only the last request is added. THe other request is
    lost, but its node keeps the down arrow. If I try to close it then,
    it crashes the app.
    My question is how do I make this code able to work with
    simultaneous requests? I already tried via AsyncToken without
    success. The main problem using tokens is how to pick the selected
    item then. =\
    Thanks in advance,
    Best regards,
    Guilherme Blanco

    Zoram wrote:
    So can u kindly advice me where should I use Servlets here in my application in order to overcome the problem.Dude, you need to study struts as well. There is an underlying servlet handling all the requests, and based on action name it decides which action class it needs to call. All this is done behind the scenes what you as a developer do is write your logic in the Action class (or may be call some services from it). So it would be easier for us, if you can share the code where you have written the logic as well your Action class code.

  • How to handle multiple requests from single client??

    hi all
    I wrote a client server program to handle requests from client.I have 2 types of requests, one is to submit comments to the server other is to view comments on the server.I have tested the app and it works fine for either of them(independently) but they don't work both together i.e when i submit a comment and view it,it's stuck and when i close the program it gives SocketException :Connection reset.
    on client side:
    My request is just a string
    on the server side:
    I check the string and give the client what it wants.
    I want to know if there's any other way to send requests other than passing it as a string.
    I can post my code if needed.
    thanks,
    Sree

    Here is my client code,minimized it to the extent possible and it might give some compilation problems since i didn't include all the functions needed but i think you should be able to get an idea if i'm doing something wrong.
    Can give you my server code if needed.
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import javax.swing.JButton;
    public class Test {
         JButton submit_button;
         JButton view_button;
         Socket client;
          JButton get_submit_button() {
                   if (submit_button == null) {
                        submit_button = new JButton();
                        submit_button.setText("Submit");
                        submit_button.addActionListener(new java.awt.event.ActionListener() {
                             public void actionPerformed(java.awt.event.ActionEvent e) {
                                  send_comments_to_server();
                   return submit_button;
               Socket check_client_connection(){
                   String host = "C001192097";     //server host name
                   if(client == null || client.isClosed()){
                    try {
                         client  = new Socket(host, 4321);
                    }catch (UnknownHostException exception){
                         System.err.println(host + ": unknown host.");
                    catch (IOException exception){
                         System.err.println("I/O error with " + host);
                   return client;
              void send_comments_to_server(){
                    try
                         Socket client = check_client_connection();
                         DataOutputStream output_stream = new DataOutputStream(client.getOutputStream());
                         BufferedReader stream_input = new BufferedReader(new InputStreamReader(client.getInputStream()));
                         String comment_report = "comments";
                         Comments comment = new Comments();
                         User_Data user_data = new User_Data(); //function that returns client details such as host name and stuff
                         String user_info = "User Name: "+user_data.user_name+" "+"Host Name: "+user_data.host_name+" "+"Domain Name: "+ user_data.domain_name;
                         comment.user_info = user_info;
                         comment.summary = comment_report;
                         comment.comments = "passing comments";
                         String report = user_info+" "+comment_report+" ";
                         output_stream.writeBytes(report+"\n");
    //                     output_stream.close();
    //                     stream_input.close();
    //                     client.close();
                    }catch(IOException e){
                         e.printStackTrace();
              void receive_comments_from_server(){
                   String line;
                   StringBuffer comments = new StringBuffer();
                   try
                         Socket client = check_client_connection();
                         DataOutputStream output_stream = new DataOutputStream(client.getOutputStream());
                         BufferedReader stream_input = new BufferedReader(new InputStreamReader(client.getInputStream()));
                         String msg = "view comments";
                         output_stream.writeBytes(msg);
                         System.out.println("waiting for response");
                             while((line = stream_input.readLine()) != null){
                                  comments.append(line);
                              System.out.println("Comments from server "+comments);     
                        } catch (IOException e) {
                             e.printStackTrace();
              JButton get_view_button() {
                   if (view_button == null) {
                        view_button = new JButton();
                        view_button.setText("View Comments");
                        view_button.addActionListener(new java.awt.event.ActionListener() {
                             public void actionPerformed(java.awt.event.ActionEvent e) {
                                  System.out.println("request sent");
                                  receive_comments_from_server();
                   return view_button;
    }thanks
    Sree

  • How to enable Sql Dependency OnDataChange event to handle multiple request at a time

    when we work with sql dependency then we work with OnDataChange event and this event notify us regarding data change in table. suppose my application monitor a
    test table by using sql dependency. suppose huge number of data is getting insert and updated in
    test table very frequently. so i do not know how sql dependency
    OnDataChange event can handle this situation because OnDataChange event will fire as many as time data will be change in db table.
    here is my snip for onchange event
    void OnDataChange(object sender, SqlNotificationEventArgs e)
    ((SqlDependency)sender).OnChange -= OnDataChange;
    BBALogger.Write("PartIndexer Service RegisterNotification called end", BBALogger.MsgType.Info);
    if (e.Source == SqlNotificationSource.Timeout)
    MailSend(); // notification mail send
    BBALogger.Write("PartIndexer Service SqlNotificationSource.Timeout error", BBALogger.MsgType.Error);
    Environment.Exit(1);
    else if (e.Source != SqlNotificationSource.Data)
    MailSend(); // notification mail send
    BBALogger.Write("PartIndexer Service SqlNotificationSource.Data", BBALogger.MsgType.Error);
    Environment.Exit(1);
    else if (e.Type == SqlNotificationType.Change)
    StartIndex();
    BBALogger.Write("PartIndexer Service Data changed", BBALogger.MsgType.Info);
    else
    BBALogger.Write(string.Format("Ignored change notification {0}/{1} ({2})", e.Type, e.Info, e.Source), BBALogger.MsgType.Warnings);
    RegisterNotification();
    please help me to design my OnDataChange event such was if data is changed very frequently in test table then
    OnDataChange can handle the situation. OnDataChange event should not be freeze and can log each data change in xml file.
    i am just looking for guidance like how to design OnDataChange as a result it could handle and log data when huge number of user will change data in test table frequently. thanks

    Hi,
    You should be able to delete all nodes selected by an XPath expression... Have a look at this...
    http://docs.oracle.com/cd/E28280_01/dev.1111/e15866/ui_ref.htm#i1290003
    Cheers,
    Vlad

  • Handling multiple requests in servlets

    Dear friends,
    in my application i have a html form and a servlet
    From LAN 60 students(clienst) will access the form simultaneously
    i have to collect data from all clients and generate a report based on their inputs
    how do i collect data from 60 clients
    regards
    Ram Mohan

    Your using html and a servlet? I suggest JSP and a servlet. I also suggest reading book on JSP that also covers servlets. Keep in mind that in proper MVC design, the JSP pages only displays data and submits back to the servlet. It doesn't contain business logic. The servlet calls business logic, gets data from business logic, puts it in request scope, then dispatches to the appropriate JSP page. The JSP page reads the data from request scope and displays it. If your not too familiar with JSP and servlets, I suggest you first create a hello world JSP page, and a hello world servlet.

  • Servlets handle multiple, concurrent requests

    Hi, folks. Could someone give me a basic idea of how Servlets handle multiple, concurrent requests which are sent from user's web browser, or possibly, point me some useful web links, tutorials. Let me take a example to make sure that i have explained the question clearly: let's say there is a website that does air ticket booking service. Suppose there is a spare seat exists for a particular flight. There are two users logon to the website and they are both looking for this particular seat. So, once these user's HTML form requests are sent to server, how do i implement my servlet to handle these requests properly, in another words, make sure this seat is only allowed booked by a single user. thanks in advance.

    This acturally raises me a another question which i
    still have some uncertainties. In another assignment i
    did last semester, that was we had multiple users
    using our database and accessing, retirving and
    updating database by using jdbc. And what i did was
    let every user call a particular method within a
    javabean for setting up database connection, then goes
    for the specific that needs to be dealt with. So, what
    i am wondering now is that can i possibly having a
    different approach, like setting up only a single
    connection(ie. a public Connection objec) which being
    exist all the time so that all request can get
    connection by calling this object's relevant method.
    Hope i explained it clearly.
    If I understand you correctly, then you would have to make the methods of this Connecting Object synchronized so that there was only ever one connection to the database at any one time.
    If a database is transactional, that means it has attempted to deal with the problem of multiple connections and statements being executed at the same time on the same data. If you have one single Connecting Object then you don't have to worry about transactions, but you do need to make sure that there aren't multiple threads running, each trying to use your Connecting Object.
    The synchronized keyword makes sure only one thread can use the synchronized method at any one time.

  • How to create/design a servcie request screen to handle multiple sets of request details ?

    Hi All,
    There is a business requirement to create a service request template to handle user account creation requests for a specific application. The inputs for this request is user name and email ID. The account creation requests are made by the dept managers. Most of the time the dept managers make multiple account creation requests at the same time.
    I have already created a service request screen that has "Username" and "Email ID" as input fields . But the problem with this design is for every single account a new service request need to be raised. 
    I want to redesign the service request screen so that it can handle multiple user account requests with a single service request. The number of users for each request varies.
    Is there a way to dynamicaly add multiple input field sets (User name and Email ID),  when creating a new service request ? or Is there any other way to achive this requirement ?
    Thanks.

    Could it be that those users you are asking permission for with this particular service request already exist in VSM system (as an example when VSM is integrated with AD)? If yes, then you can use custom Multiple Value QD [of the Person entity] to select required persons and add as many persons as you like to your request.
    Otherwise it may require deeper analysis of your business requirements. For now I have only some ideas to use Service Actions or custom javascript to create more advanced customer portal interface.
    In this case I would suggest to contact Alemba PSO for an extra service if possible.
    Regs, Gytis

  • How to handle multiple clients with DatagramSocket

    I am trying to handle multiple clients with 1 datagramSocket bind to one port (basically I have only one port to use, and I can not use TCP or any other ports). At the server side I have two threads one for receiving packets and buffering them, another for processing the packets in the buffer and sending replies.
    I can have multiple clients sending datagramPackets to me and I will have to process the packets and send them to DIFFERENT clients. Ex. Client 1 sends datagramPacket to Server which sends the processed packet to Client 2. Also Client 2 sends a datagramPacket to Server which again processes the packet and sends it to Client1. May have Client 3 and 4 doing the same thing at the same time... and so on...
    My root class is creating the datagramSocket(somePort) and two threads (receiver and sender). How can I use the socket that I created in these two threads??
    I have done the following and I am getting "java.net.bindexception". When I am sending stuff from Client1 to Client2 everything is fine but when I start sending something from Client2 to Client 1, I get the bindexception... Client 1 is using port 3000, Client 2 is using port 4000.
    I really don't have a lot of experience in socket programming so I am not sure if there is a much simpler way to do this. I appreciate all the tips and help that I can get...
    Thanks...
    class UDP_serv
         static DatagramSocket udpSocket;
         final static int SERVER_PORT     = 2000;
         public static void main(String[] args) throws SocketException
              udpSocket= new DatagramSocket(SERVER_PORT);
              new DataReceiver().start ();
              new DataSender().start ();
         static class DataReceiver extends Thread
              DataReceiver()
                   Thread.currentThread().setName("DataReceiver");
              public void run()
                   while (true)
                        byte pckt[] = new byte [MaxMsgSize];          
                        DatagramPacket dp = new DatagramPacket (pckt, pckt.length);
                        try
                             udpSocket.receive (dp);
                             //PUSH TO RECEIVE BUFFER
                        catch(Exception e)
                             e.printStackTrace();
         static class DataSender extends Thread
              DataSender()
                   Thread.currentThread().setName("DataSender");
              public void run()
                   while (true)
                        processDataMsg();
          static void processDataMsg() 
             DatagramPacket op;
             InetAddress DA = null;
             int DP = 0;
             byte [] outPacket = null;
             // POP FROM RECEIVE BUFFER
             // SOME PROCESSING HERE     
             // Set Destination Address (DA)
             // Set Destination Port (DP)
             // DA and DP are the forwarding IP and Port addresses
             // not the addresses original packet was sent from.
             try
              op = new DatagramPacket (outPacket, outPacket.length,DA, DP);
              udpSocket.send(op);
             catch (IOException e)
              e.printStackTrace();
    }Also for development and testing purposes, I am running the two clients and the server on the same machine (windows xp-32b) so all of the Destination IP Addresses are 127.0.0.1. and as I said Ports that I am using are 2000, 3000, 4000 (Server, Client1, Client2).

    Hmm I have minimized the code and it seems to be working now.
    I think I have an error in the header portion of the data I am sending, where I am storing the source IP/Port and destination IP/Port. I think the server in the middle is messing these values up while sending them to the destination Client. Because the destination client actually receives the stuff and sends the reply back to the server, but the reply packet's headers has 0/0 as the dest IP / Port...
    Server is giving me java.net.BindException: Cannot assign requested address error when it tries to forward the reply it received from the client2 as the address it is trying to send is 0!
    I guess it doesnt just give this error when you try to open two sockets to the same port...
    Paul, Thanks for the direction on how to proceed... took me a while get the minimized code but at least figured out the problem. Well still have to make sure that is THE problem though :)
    As far as the statics goes how can I change those to non static ones? Where do I make an instance of the top level class that creates the threads? and how do I pass the DatagramSocket to the threads/ if I dont need to pass how do I call or use the datagramSocket I created in the top level class? I mean do I still kinda have it like a global variable on the top?? A very simple example would be much appreciated...
    I think these might be really basic questions but I am having a rough time with the hierarchy in java...

  • Handling multiple submits in single form with JSP

    HI,
    I need to handle multiple submits in single form in a JSP.
    <html>
    <body>
    <form action="/Compute" method="post">
    <input type = "Submit" value="Find"/>
    <input type = "Submit" value="Add"/>
    <input type = "Submit" value="Delete"/>
    </form>
    <body>
    <html>
    /Compute wld take the control to a servlet named ComputeController.java .
    In this servlet how should I distinguish which Submit has been clicked(Find or add or Delete).
    TIA

    Give the submit button a name. It will be sent as well, so you can see it in the request variables.

  • URGENT:Handle multiple connection in a multithreaded server.

    I hava a multithreaded server where it can handle multiple connection.
    The program works in this way. First, it will wait for connection. Once it accepts a connection, it will pass the socket to a thread class which will in turn process the connection. Then, the server will go back to the infinite loop to wait for new connection.
    Since I am not very familiar on using thread, I would like to post the following questions:
    1) Let say that my server can handle multiple connections. This is to cater for the different requests from the client. For instance, the client may make one connection for chatting and another connection for sending file(something like we have in Yahoo Messanger). So, at the server side, how can I differentiate between the connection for CHAT and the connection for SEND FILE so that I can handle the requests separately. It means I can save the file sent from client and display the chat message in the JTextArea?
    2) How can I stop the server, clean up the thread and start the server again for waiting new connection? Currently, I can just start my server once.
    For reference,following are parts of my program:
    public void listenSocket(){
    try{
    server = new ServerSocket(5000);
    } catch(IOException e) {
    System.out.println("Failed to listen on port 5000");
    System.exit(0);
    try{
    while(true){
    server1frame sframe=null;
    ChatHandler handler;
    handler = new ChatHandler(sframe,server.accept(),jTextArea1,jTextField1,jFileChooser1);
    handler.start();
    } catch(IOException e) {
    System.out.println("Accept failed:5000");
    System.exit(0);
    //to close the connection as the final steps before program exit.
    } finally {
    try{
    server.close();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    public void run() {
    out.println("Connection Established");
    out.flush();
    try {
    String line;
         while(!(line =in.readLine()).equalsIgnoreCase("QUIT")) {
    if(line.startsWith("CLIENT"))
    jTextArea1.append("\n"+line);
    else if(line.startsWith("Connecting")) {
    jTextArea1.append("\n"+line);
    else if (line.startsWith("Finish")) {
    JOptionPane.showMessageDialog(sframe,"File has finished downloading",
    "File Download Complete",JOptionPane.INFORMATION_MESSAGE);
    else {
    BufferedWriter fout = new BufferedWriter(
    new FileWriter("e:/num1.txt",true));
    fout.write(line);
    fout.newLine();
    fout.flush(); }
         } catch(IOException ioe) {
         ioe.printStackTrace();
         } finally {
         try {
              in.close();
              socket.close();
         } catch(IOException ioe){
    System.out.println("Fail to close connection.");

    1) Let say that my server can handle multiple
    connections. This is to cater for the different
    requests from the client. For instance, the client may
    make one connection for chatting and another
    connection for sending file(something like we have in
    Yahoo Messanger). So, at the server side, how can I
    differentiate between the connection for CHAT and the
    connection for SEND FILE so that I can handle the
    requests separately. It means I can save the file sent
    from client and display the chat message in the
    JTextArea?Either your server listens on two different ports for two different protocolls, (then you would a server thread for each port) or you accept connections for both protocolls on both ports, and have the client state what protocoll it is using :
    eg:
    accept Connection - start new Thread - read first line - depending on protocoll pass protocoll object (CHAT, FTP) to run method
    There is an example for a simple protocoll at : http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
    2) How can I stop the server, clean up the thread and
    start the server again for waiting new connection?
    Currently, I can just start my server once.You normally start servers only once. It should then be up and listening for it's entire lifetime. Restarting a server should only be needed if it hangs or crashes.

Maybe you are looking for

  • Why do all my artist albums not display in the list format but do when i look at albums

    When I list my songs by artist not all of the albums are listed for some people, but when I turn my phone sideways all the missing albums do show up with album covers and the songs.  What can I do to fix this?

  • Weird import statement problem

    Hi I have a strange problem with an application I just developed. Once compiled, if I try to run it on another machine other than the one I developed on, I get a NoClassDefFoundError relating to a class that I did not use. I look at the class file (i

  • Lenovo G550 EISA partition problem

    Hello, I have Lenovo G550 whit Windows Vista Home Basic(bay it whit this OS and whithuot Recovery CD). By mistake i delete eisa partition when installing MacOSx.After that I restore all files from EISA partition to my other partition. So my question

  • Adobe 8 Pro serial is invalid after trying to move from one pc to another

    So I've de-activated the key from computer (a - win7 64bit) and uninstalled it. Then when I try to use that same key on computer (b - win 7 64 bit) it says it's invalid.

  • Trouble mounting cd &/or cdrw drives

    New arch install on PIII, XFCE4.  Cd drive is primary, cdrw is slave. $hwd -s cd     /dev/hdc cdrw /dev/hdd fstab /dev/hdc   /mnt/cdrom   iso9660  ro,user,noauto,unhide 0 0 /dev/hdd  /mnt/cdrw       iso9660 rw,user,noauto,unhide 0 0 I've tried to mou