Exchange POST data between servlets?

Hello all
First of all, my apologies for my English. This is the first time writing to forum.
I�m new to java and I need a little help with servlets.
I have the servlets A, B and C.
Servlet A just display a page with a form tag witch send the data to Servlet C via POST method. What I want is to intercede the Servlet B between them and check the integrity of those POST data.
For example: Servlet A send data to Servlet B via POST method, Servlet B check the integrity of those data, and finally Servlet B send those data to Servlet C via POST method.
For now the only I have done is to send the data to B and transfer the data to C with GET method.
How can I send data with POST method in a servlet?
The code so far:
     String urlstr = new String();
     String str1 = request.getParameter("st_name");
String str2 = request.getParameter("st_birth");
String str3 = request.getParameter("st_class");
��some check ����
     urlstr = "/student/check_st?st_name=" + str1 + "&st_birth=" + str2 + "&st_class=" + str3;
     response.sendRedirect(urlstr);
Thanks in advanced.
Ilias

You should use the RequestDispatcher.forward(request,response) method.
For example, inside Servlet B do this:
public void doPost(ServletRequest request, ServletResponse response) {
    ... validate parameters ...
    RequestDispatcher dispatcher = request.getRequestDisplatcher("ServletC");
    dispatcher.forward(request,response);
}This prevents an extra request-response cycle to the client and between the .forward() and .include() methods of the RequestDispatcher, should be considered the preferred way of server-side redirection unless there is a specific need to go to the client first.
See the J2EE API:
http://java.sun.com/javaee/5/docs/api/

Similar Messages

  • How to make the exchange of data between 2 while loop in real time

    hello
    I have 2 while loop
    the 1st while loop includes the data acquisition program
    the 2nd while loop includes the control program
    my question is how to make the exchange of data between 2 while loop in real time
    I tried with the local variable and direct wiring between the 2 while loop
    it does not work (there is a delay)
    Solved!
    Go to Solution.

    Bilalus,
    Queues are only good to transfer data if your application isn't deterministic. Since you are using Real Time, I am assuming that your application requires determinism. If you are using Timed Loops and you use queues to transfer data between your loops, you are losing determinism. In this case, you need to use the RT FIFO functions. 
    Warm Regards,
    William Fernandez
    Applications Engineering
    National Instruments

  • Transfering data between servlets

    hi
    how would i transfer data between servlets - Im creating a form (form1) which asks the user to enter information - the user then submits, and this takes them to the next form (form2) - i need to transfer the data from form1 to form2 (ie. name, lastname). code follows
              // set content type
              response.setContentType("text/html");
              // then write the data of the response
              out = response.getWriter();
              out.println("<HTML><HEAD><TITLE>" + Title + "</TITLE></HEAD><BODY BGCOLOR=white>");
              out.println("<H2>Customer Registration Form</H2>");
              //create link to servlet action = pathOfServlet?
              out.println("<FORM action = \"ServletExample1\">");
              out.println("First name: <input type=text name=\"name\" value=\"" + name + "\">");
              out.println("Last Name: <input type=text name=\"lastName\" value=\"" + lastName + "\"><P>");
              //value=\"female\" -- forward slash enters html/java and ends java
              out.println("Male<input type=radio name=\"gender\" value=\"male\"> ");
              out.println("Female<input type=radio name=\"gender\" value=\"female\"><P>");
              out.println("Telephone: <input type=text name=\"phone\" value=\"" + phone + "\">");
              out.println("Email: <input type=text name=\"email\" value=\"" + email + "\"><P>");
              out.println("<INPUT TYPE=SUBMIT><P>");
              out.println("</FORM>");
              // then write the data of the response
              out = response.getWriter();
              out.println("<HTML><HEAD><TITLE>" + Title + "</TITLE></HEAD>\n");
              out.println("<BODY BGCOLOR=white>");
              out.println("<H3>Credit Card Information</H3>");
              out.println("<FORM>");
              out.println("First name: <input type=text name=\"name\" value=\"" +should i link here+ "\">");
              out.println("</BODY></HTML>");

    Have you tryed using the request parameter? It should contain what you seek, I think.
    Here for example;
    String firstName = request.getParameter("name");
    String lastName = request.getParameter("lastname");Use that in the second form, which should get its parameters from form1.

  • I have an I phone and I pad under same Apple ID, I want to stop exchange of data between both how?

    I have an I phone and I pad under same Apple ID, I want to stop exchange of data between both how?

    And in settings/iTunes &amp; App Store you need to turn off auto download

  • Foreign Exchange - Posting date - updation - Not Working Properly

    Hi Friends,
    At the time of posting the Purchase invoice in Transaction Code MIRO, the system is picking the Exchange rates form the table based on our posting date in the Invoice screen.
    System is not updating the exchange rate, if we change the Posting date just before posting.
    Example:
    Transaction code MIRO
    Posting date 21.01.2010; Exchange rate picked by system - 46.67 (USD and INR) Maintained in Table - 21.01.2010 - Rs.46.67
    before posting we are changing the posting date from 21.01.2010 to 22.01.2010
    Posting date 22.01.2010; Exchange rate picked by system - 46.67 (USD and INR) maintained in Tabl - 22.01.2010 - Rs.46.99
    To bring the correct exchange rate into effect, We are coming out of the Transaction code and Re-entering the correct posting date.
    Is there is any solution to make the system pick the exchage rate whenever we change the posting date?
    Thanks in advance friends and collegues

    Thanks for Quick reply
    I have a separte Exchange rate in PO (purchase Order) and I have not activated the fixed Exchage rate in the Purchase Order
    If I have activated the Fixed Exchange rate in Purchase order - then the system will not accept other Exchange rates in Transaction Code MIRO (booking LIV)
    I have not activated the Fixed Exchange rate in Purchase order (Please have a look at the Purchase Order - A check box for maintaining the Fixed Exchange rate through out the P2P Cycle.
    If the fixed exchange rate is notactivated in PO, the system will pick the Posting Date in the Transaction Code MIRO (LIV) for calculating the Exchange rate.
    Now my query is why the system is not changing the Exchange rate automatically when I change the Posting date in Transaction Code MIRO. Please also let me know what should be done from our side so that whenever I change the posting date in Transaction Code MIRO, the system should pick the Exchange Rate according to the Posting Date in Transaction Code MIRO.
    Thanks for showing Interest
    Thak you and Kindest Rgeards
    Srikaanth

  • How to Recieve a POSTed data by Servlet

    How can I recieve a POSTed data by Sevlet doPost Method?
    Raheel

    No, I cannot use getParameter because a XML Request is posted to the Servlet and my Servlet has to parse that servlet using DOM.
    My code is as follows:
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    document = builder.parse(new InputSource(requst.getReader())); --- A
    I am facing SAXParseException that Content not allowed in Prolog at point A.
    Any Help
    Thanks
    Raheel

  • Can't send POST data from servlet

    Hi,
    I have a servlet that receives data via GET method, process the request and then it has to send feedback to an url, but the query string that
    I have to send must be in a POST method.
    I ilustrate this:
    http://host:port/myservlet?param1=value1
    myservlet proccess and then calls
    http://external_url (with param2=value2 via POST)
    I've tried to put an HttpURLConnection
    URL url = new URL("http://localhost:7001/prueba.jsp");
    java.net.HttpURLConnection con= (HttpURLConnection)url.openConnection();
    //POST data
    URL url = new URL("http://localhost:7001/prueba.jsp");
    HttpURLConnection c = (HttpURLConnection)(url.openConnection());
    c.setDoOutput(true);
    PrintWriter out = new PrintWriter(c.getOutputStream());
    out.println("param2=" + URLEncoder.encode("value2"));
    out.close();
    but I get this error.
    lun mar 10 13:53:46 GMT+01:00 2003:<W> <ListenThread> Connection rejected: 'Login timed out after 5000 msec. The socket
    came from [host=127.0.0.1,port=2184,localport=7001] See property weblogic.login.readTimeoutMillis to increase of decreas
    e timeout. See property weblogic.login.logAllReadTimeouts to turn off these log messages.'
    (it's a weblogic 5.1 problem, i've been researching a little bit)
    And I don't want to call a jsp that generates a post form, and then it's auto-submitted with javascript. (this will be the last remedy!!)
    How can i do this?
    All suggestions will be grateful.
    Thanks in advance.
    PD: sorry for my english :)

    I make an URLConnection and I intended to know if the post data was
    sent right. Then, in my machine, under weblogic 5.1, I developed a jsp with this code:
    <%
    URL url = new URL("http://machine2/examples/prueba.jsp");
    HttpURLConnection c = (HttpURLConnection)(url.openConnection());
    c.setDoOutput(true);
    PrintWriter outd = new PrintWriter(c.getOutputStream());
    outd.println("param1=" + URLEncoder.encode("value1"));
    outd.close();
    c.disconnect();
    %>
    and in machine2 (using tomcat 4.1), I simply put a line in prueba.jsp:
    System.out.println(request.getParameter("param1"));
    and I don't get "value1" in the tomcat log as expected (I think).
    I also tried with adding this properties:
    c.setRequestProperty("Content-Length", size...);
    c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    and it didn't work!
    what's wrong?

  • I have iPhone4 and iPhone 4S-16G, can I exchange the data between this 2 iPhones?

    As I don't want the data being mixed between this 2 iPhones.

    If you want to exchange the data (I am thinking sync), use the same apple ID. If you don't want them to interact at all, use a different Apple ID and set up a new iCloud for the other phone.

  • How to exchange information(parameters) between servlets & jsps

    with an examle if possible.

    Hi
    Exchanging parameters/objects between JSP and Servlets is done by creating an Object and placing it in the ServletContext , User Session or the Request depending on whether the Object requires Application Wide scope, Session Scope or Request Scope respectively.
    If the object is created in the Servlet then it can shared by placing it in either Context, Session or Request through the setAttribute method and similarly retrieved through the getAttribute method.
    For JSP use the <jsp:useBean> tag to retrieve/create the Object (bean).
    For eaxmples see the following Links:
    http://java.sun.com/docs/books/tutorial/servlets/communication/attributes.html
    http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html#JSPIntro11
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems
    http://www.sun.com/developers/support

  • Loosing session data between servlets...

    Based on the code below I'm loosing the session data i.e the class indexed by the session id is returning NULL. If anyone has any suggestions I would apprciate it.
    Class 1:
    HttpSession session = request.getSession(true);
    Hashtable books = (Hashtable) session.getValue("books");
    if (books == null)
    books = new Hashtable();
    else
         books = null;
         books = new Hashtable();
    session.putValue("books", books);
    Class 2:
    HttpSession session = request.getSession(true);
    Hashtable booksOrdered = (Hashtable) session.getValue("books");
    System.out.println("booksOrdered: "+ booksOrdered):
    The system.out.println statement returns
    booksOrdered: NULL
    Help please
    Lee Paulison Jr

    I forgot to mention that the code was working up until I installed the March 4 - 28 2002 Windows NT Critical updates. The code worked after the update when I changed to a different login name namely Admin. Then after a few hours it stopped working, and continues not to work on any Login. I hope that this last bit of information helps someone come up with a fix.
    Lee Paulison

  • AP- Why exchange rate type between Post invoice and Post payment is differe

    AP- Why exchange rate type between Post invoice and Post payment is different ?
    Hello,
    I have question
    when post AP invoice , document type KR
    document date = 11.12.2009
    posting date = 31.12.2009
    entry date = 05.01.2010
    this document using exchange rate type B (standard translation at bank selling rate) on 31.12.2009 (use posting date )
    but when post payment for above document,document type ZP
    document date = 25.06.2010
    posting date = 25.06.2010
    entry date = 24.06.2010
    this document using exchange rate type M (standard translation at average rate) on 23.06.2010
    please answer
    why do post invoice and post payment use different exchange rate type?
    and why at payment donot use posting date for get exchange rate ?

    Nanas,
    Sorry if im not  being clear...
    My point is: the difference rates customization for payments is done at FBZP.
    At Paying Company Codes, you have 4 flags for exchange rates differentes.
    At Control Data look:
    *Do not Post any Exchange Rate Differences:
    If the indicator is not set, the difference between the exchange rate at the time of posting and the exchange rate at the time of payment is determined for items which are posted in foreign currency. The payment program uses the translation rate in the currency table in the system for this purpose.
    *No Exchange Rate Differences for Partial Payments:
    Has the effect that the payment program for partial payments (requests for payment using transaction F-59) does not post exchange rate differences.
    *Processing of Bill of Exchange Payments:
    *Separate Payment for each Payment Reference
    Regards
    Bruno

  • Exchange rate coefficient on the basis of latest posting date in invoice.

    Hi,
    I have one query on posting date(picking of exchange rate coefficient from TCURR table) in invoice verification.  Please help.
    Conditions are--
    vender and company code are not in same currencies(ex-USD and INR). exchange currencies are maintained perfectly on every month 1st ie co-efficients in TCURR table ie OB08
    Query---
    1.At the time of parking invoice suppose i enter the date 20th august and i have posted that invoice as parking. It is converting the local currency as per 8th month exchange rate.
    2.And at the time of final posting the invoice supose i posted that date as 10th September. Business wanted that converting the local currency as per 9th month exchange rate But now local currency is converting on the basis of initial entry of posting date ie 8th month only.
    Please advise and guide what configeration that i have to set for picking the exchange rate coefficient on the basis of latest posting date in invoice verification.
    Thanks & Regards,
    MadhuBabu.

    Hi
    I dont think it is possible as once you enter posting date while in parking invoice screen, on that date exchange rate will be calculated and it wil not be different at time of posting invoice. Instead of parking, you have to directly post with current posting period.
    Thanks

  • MIR7 exchange rate is not modefied with respect to posting date

    Hi Experts,
    In our SAP system , we use MIR7 to create park invoice at first ,and then use MIR4 to change the parked invoice and post it.
    but when creating parked invoice, it's in say June and the exchange rate is 100, and when we create real invoice from parked invoice, it's October and exchange rate turns to 115.
    Then I change the posting date in the invoice from June to Ocetober, but the exchange rate is still 100 it is not changing according to the new posting date. How can I solve this problem, please give me a solution a.s.a.p.
    Thanks in advance for your help.
    Regards
    Sunil

    Hi Pankaj,
    There are so many options e.g you can check in oinm select that particular item sort on docdate and check inqty and compare with your goods issue date if it is same then send same transaction to approval if you want.
    Thanks
    Sachin

  • Difference between doc date,posting date and invoice date

    hi bw guys
    can someone give a brief on the difference between doc date,posting date and invoice date.and the invidual definitions
    thank you

    Hi,
    Posting Date: Date which is used when entering the document in Financial Accounting or Controlling. The posting date can differ from both the entry date and the doc date.
    Document Date: The document date is the date on which the original document was issued. Ex: Inv date, Bill date etc.,
    Invoice Date : Usually the date when goods are shipped. Payment dates are set relative to the invoice date.
    -Vikram

  • Difference between Posting Date and Posting Day

    In Accounting Document Header table BKPF, there are 2 fields: BUDAT (Posting Date) and PSOBT (Posting Day), both of DATS type. What is the difference between the two?
    Why is that substitutions and Business Transaction Events allow changing of Posting Day (PSOBT) and not BUDAT (Posting Date)?
    In that case, how can I change the Posting Date of a document based on certain rules?
    Thank you.

    Hi,
    13 period is a special accounting period, so the situation you described is perfectly normal. The reversal document will be posted in the same period.
    You can read more about special periods here:
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/96/8b2fef43ce11d189ee0000e81ddfac/frameset.htm
    Regards,
    Eli

Maybe you are looking for