The responses of servlets called by an applet

I'd like to do so that my applet calls a servlet, sending to it some data, and that the response of my servlet is displayed in my applet's frame, as any HTML page.
How can I do that ?
Thank's.

Your applet to servlet communication is as object streams.So while sending data to servlet you do,
HttpURLConnection connection = (HttpURLConnection) urlServeur.openConnection();
connection.setRequestProperty("Content-Type", "application/octet-stream");
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(false);
ObjectOutputStream oos = new ObjectOutputStream(connection.getOutputStream());
oos.writeObject(entreprise);
oos.flush();
oos.close();
Note: DoOutput(false) is there.
For your applet to read the data back you have to do the same like this,
public InputStream sendPostData(java.util.Hashtable args) throws java.io.IOException
     URLConnection con = servlet.openConnection();
     if((args != null))     {
          con.setDoInput(true);
          con.setDoOutput(true);
          con.setUseCaches(false);
          con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
          ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
          out.writeObject(args);
          out.flush();
          out.close();
     return con.getInputStream();
you read the objects from the stream and do whatever u want.
In servlet you have to make sure to serialize the objects or use objects that implement serializable and write in a output stream like this,
private void writeOutput(HttpServletRequest req,HttpServletResponse res,java.util.Hashtable hash) throws java.io.IOException {
          ObjectOutputStream out = new ObjectOutputStream(res.getOutputStream());
          out.writeObject(hash);
          out.flush();
          out.close();
Hope it helps.!Good Luck.!

Similar Messages

  • Delay in the Response Group Rining / Call Pickup from another Extension

    Dear All,
    We have just finished a deployment of Lync 2013 with Sonus 1000 as the Mediation Gateway, we have deloyed polycom VVX 600 phones,
    We have two lines E1 and 5 Fxo lines (with same Pilot Number)
    I would like the Receptionist to have both E1 DID number and FXO number and her phone to ring when the calls comes from DID line as well as FXO,
    I have the below scenario
    1) Currently the setup is that Receptionist is configured with the E.164 DID number : (Line URI is Tel:+971XXXX500;ext=500), which work perfectly fine
    2) We have added receptionist in Response Group , and setting are (Formal,10 sec , Attendant)
    The issue :
    1) Call forwarding does not work on Response Group (which is by design it self)
    2) When a call comes from the outside to FXO it goes to response group , (there is Music played and the ring on reception is delayed by 2-3 secs) ,
    Customer does not want this delay , it should ring immediately with no music,
    3) If the receptionist moves from one location to any other location to another , she should have the ability to remotely perform call forward to that extension by simply dialing few codes on the phone ( I already told customer
    about PIN based authentication, by customer does like the idea of signing in or signing out)
    In DIRE NEED OF HELP,
    Regards,
    Hasan Reza,

    Hi,
    Did the issue only happen for IP Phone in Response Group or also happen for Lync client in Response Group?
    If the issue only happen for IP Phone, it seems to be an known issue. Please Make sure Lync Server update to the latest version and then test again.
    Here are several similar case may help you:
    https://social.technet.microsoft.com/Forums/lync/en-US/196375a5-3ae9-4452-acbe-2679a8deef80/delay-when-response-group-calls-are-answered
    https://social.technet.microsoft.com/Forums/lync/en-US/70306bf5-fcd3-488a-b6f4-2eee1bcc0457/lync-2010-ip-phone-calls-and-response-group-delays
    Best Regards,
    Eason Huang
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Eason Huang
    TechNet Community Support

  • Inconsistent behaviour of the response

    Hi Everyone,
    We have a very weird problem here. Our application is a servlet based app using iPlanet Enterprise 4.0 application server. The servlet response acts very inconsistent when we try to change the response type from text/html to something else in the application(to res.setContentType("application/vnd.ms-excel") for example). Sometimes it works but most of the time instead of opening results in MS Excel, output is being rendered as an HTML.
    Does anyone have any suggestions?
    Any help will be greatly appreciated.
    Thanks,
    YM

    First of all I am setting the response type by
    calling
    res.setResponseType("application/vnd.ms-excel");Then I call some classes to query the database and
    return the ResultSet, which I then pass to the
    formatting classes to create an HTML page and write
    the ResultSet in the form of an HTML table inside the
    page. After that's been done, I get PrintWriter out
    of the response and writing the page by calling
    PrintWriter out = res.getWriter();
    out.print(formatted_HTML_page);
    Sorry, I meant res.setContentType

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • What is the best way to call a servlet from another servlet?

    I have a project with 9 servlets (class project). The way I have been moving from servlet to servlet is like this
    doPost(...)
    {      response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>Functions</title>");
    out.println(f"<form name=frm6 method=post action=/servlet2");
    out.println("<input type=submit name='btn' value='servlet2'>");
    out.println("</form>");
    So I have these 9 servlets - I call any 8 of them from the first servlet so I have 8 buttons on 8 forms <form=frm1, frm2, ...frm8 method = post...> But when I bring up the first servlet only 6 buttons show up. I was thinking about using hyperlinks instead, but I would like to do this with buttons. I wanted to do this with javascript and the location object, but I was advised to use jsp. I just want to move from one servlet to the next. Any suggestions appreciated for the best/preferred method for moving from one servlet to the next.
    Thanks

    I think you may need some clarification of terminology etc..
    First off, JSP isn't an alternative to javascript, it's an alternative to coding a servlet. A JSP is a mixture of java code and HTML and is translated into a servlet by the system. JSPs are primarilly for generating HTML pages with variable content. JSPs very frequently generate HTML which includes Javascript.
    You probably shouldn't think of what you're doing as one servlet invoking another, that does happen; a servlet can transfer an transaction to another servlet or JSP. In fact it's standard practice that a servlet does the logical stuff (like interpretting form data) then transfers to a JSP to generate the response page. However in this case it's the browser that can invoke one of the 8 servlets, the first servlet merely creates the page from which they are invoked.
    It's not obvious why only some of your buttons are showing up. In a case like this use the "view source" option on your browser to find out what HTML the servlet is actually delivering. What's wrong should be evident from that.
    You can put a hyperlink arround a button, or an image. Mostly people turn up their noses at the buttons supplied by HTML and use their own images for buttons. You
    can do somthing like this:
    <img src="/images/button3.png" border="0">
    (Of course this arrives as a GET transaction not a POST).
    Or you can do a bit of javascript like:
    <img src="/images/button3.png" style="Cursor: pointer;"
    onclick="document.locations.href='/servlet3';">

  • Recall the servlet after it had generated the "response"  page

    Hi Everybody !
    I have a big problem and i am front it since i am programming in servlet/jsp .
    The basic scheme in the tutorial is form.jsp => call and processing by the servlet => response.jsp .
    That i want to do is : simple form.jsp=> call and processing by the servlet (with method 1) => response1.jsp (which is a more complete form) => call and processing by the servlet (with method 2 which it is unlike method 1) => response2.jsp (final page).
    But i don't know how to do it : you don't understand with i want to make it ? so there is a simple example: a user want to know what he have eaten at a day:
    1)my first simple form.jsp: ask to the user his name and a date
    2)the response 1 and page 2 is return: it's a more complex and complete form (this page is well generate in my project )
    with this date and the name of the user, i question my database : "what this user have eaten at this date "?
    For example : at this date, he ate : chips at the aperitif and apple for dessert .
    The user must to complete the page 2 with more information (which have to be insert in the database):
    ex:
    had he ate this apple : in the kitchen, in the park, at his work ...?? (drop-down menu)
    had he ate this apple : baked, uncured ...?? (another drop-down menu)
    To resume: i want it's to recall the servlet with another button (with a name different in the servlet) to a specific method.
    in the first and simple form there is a button ONE that call the method1 of the servlet
    the servlet generate the page 2 (more complex and intermediate page)
    in this page 2 more information is asked to the user and there is a button TWO that call the method2 of the same servlet
    the final page (3) is generated by the servlet.
    So i success in the generation of the page 2 but when i click on the button TWO the controler (urlAction) send me null !!
    the call to the servlet is not done !
    some code:
    the servlet :
    public class ServletFichePrlvLEGactual extends HttpServlet{
         private String urlErreurs = null;
         private ArrayList erreursInitialisation = new ArrayList<String>();
         private String[] param�tres = {"urlFormulaire", "urlControleur","urlReponse","urlErreurs","urlReponseBis"};
         private Map params = new HashMap<String, String>();
         private ResultSet resultSetIDPrelevement;
    //     init
         @SuppressWarnings("unchecked")
         public void init() throws ServletException {
              // on r�cup�re les param�tres d'initialisation de la servlet
              ServletConfig config = getServletConfig();
              // on traite les autres param�tres d'initialisation
              String valeur = null;
              for (int i = 0; i < param�tres.length; i++) {
                   // valeur du param�tre
                   valeur = config.getInitParameter(param�tres);
                   // param�tre pr�sent ?
                   if (valeur == null) {
                        // on note l'erreur
                        erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
                   } else {
                        // on m�morise la valeur du param�tre
                        params.put(param�tres[i], valeur);
                   // l'url de la vue [erreurs] a un traitement particulier
                   urlErreurs = config.getInitParameter("urlErreurs");
                   if (urlErreurs == null) {
                        throw new ServletException(
                        "Le param�tre [urlErreurs] n'a pas �t� initialis�");
         @SuppressWarnings("unchecked")
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // on v�rifie comment s'est pass�e l'initialisation de la servlet
              if (erreursInitialisation.size() != 0) {
                   // on passe la main � la page d'erreurs
                   request.setAttribute("erreurs", erreursInitialisation);
                   getServletContext().getRequestDispatcher(urlErreurs).forward(
                             request, response);
                   // fin
                   return;
              // on r�cup�re la m�thode d'envoi de la requ�te
              String m�thode = request.getMethod().toLowerCase();
              // on r�cup�re l'action � ex�cuter
              String action = request.getParameter("action");
              // action ?
              if (action == null) {
                   action = "init";
              // ex�cution action
              if (m�thode.equals("get") && action.equals("init")) {
                   // d�marrage application
                   doInit(request, response);
                   return;
              if (m�thode.equals("post") && action.equals("valider")) {
                   try {
                        doInterrogationFormulaire(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              if (m�thode.equals("post") && action.equals("testAffichage")) {
                   // validation du formulaire de saisie
                   try {
                        dotestAffichage(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              // autres cas
              doInit(request, response);
         void doInit(HttpServletRequest request, HttpServletResponse response) throws ServletException,
         IOException {
    //          on r�cup�re la session de l'utilisateur
              HttpSession session = request.getSession(true);
              // on envoie le formulaire vide
              session.setAttribute("nomCentre", "");
              session.setAttribute("NEtude", "");
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                        request, response);
              return;
         void doInterrogationFormulaire(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres
              String nomCentre = (String) request.getParameter("nomCentre");
              String NEtude = (String) request.getParameter("NEtude");
              //puis on le stocke dans la session
              HttpSession session = request.getSession(true);
              session.setAttribute("nomCentre", nomCentre);
              session.setAttribute("NEtude", NEtude);
              Connexion com = new Connexion();
              try{
                   String query="SELECT idEtabl FROM Etablissement WHERE NomEtabl='"+nomCentre+"'";
                   ResultSet idCentre = com.ConnectAndQuestion(query);
                   idCentre.first();
                   String resulstatId=idCentre.getString("idEtabl");
                   String queryidPrelevement="SELECT idPrelevement FROM Etabl_Prlvmt where NEtude='"+NEtude+"' AND idEtabl='"+resulstatId+"'";
                   resultSetIDPrelevement=com.ConnectAndQuestion(queryidPrelevement);
                   if(resultSetIDPrelevement.next()!=false){
                        resultSetIDPrelevement.beforeFirst();
                        request.setAttribute("resultSetIDPrelevement", resultSetIDPrelevement);
                        getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(
                                  request, response);
                        com.close();
                        return;
                   else {     
                        getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                                  request, response);
                        com.close();
                        return;
              catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");
                   getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                             request, response);
                   return;          
         void dotestAffichage(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres d'int�ret
              ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
              Connexion updatePrlvmt= new Connexion();
              try{     
                   //serveur,login,pwd,database
                   updatePrlvmt.loadDriverAndConnect("127.0.0.1","3306","root","root","");
                   int k=1;
                   while (resultSetIDPrelevement.next()){
                        String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");               
                        if (request.getParameter("choix"+k) !="Vl"){                         
                             String champModalite=(String) request.getParameter("modalite"+k);
                             String champExutoire=(String) request.getParameter("exutoire"+k);
                             String queryUpdate="UPDATE PrelevLEG SET Modalite='"+champModalite +
                             "',Exutoire='"+champExutoire +
                             "',Temp='null',TempMax='null',Heure='null' WHERE idPrelevement='"+idPrelevement +
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                        if (request.getParameter("choix"+k) !="Ef"){
                             String queryUpdate="DELETE FROM PrelevLEG where idPrelevement='"+idPrelevement +"'";
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                   updatePrlvmt.close();
              }catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");     
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlReponseBis")).forward(request,
                        response);
              return;
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException {
              // on passe la main au GET
              doGet(request, response);
    the web.xml:<servlet>
         <servlet-name>FichePrlvLEGactual</servlet-name>
    <servlet-class>germande.LEG.ServletFichePrlvLEGactual</servlet-class>
         <init-param>
    <param-name>urlFormulaire</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formInterrogationActualPrlvmtLEG.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlErreurs</param-name>
    <param-value>/erreursRecap.biotech.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponse</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponseBis</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/respFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlControleur</param-name>
    <param-value>ServletFichePrlvLEGactual</param-value>
    </init-param>     
    </servlet>
    the first simple form:<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%
    // on r�cup�re les param�tres
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <html>
    <head>
    <title>Fiche R&eacute;sultats Legionelles - formulaire</title>
    </head>
    <body>
    <center>
    <h2>Fiche R&eacute;sultats Legionelles - formulaire</h2>
    <hr>
    <form action="<%= urlAction %>" method="post">
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
         <td><input name="nomCentre" value="<%=nomCentre%>" type="text" size="20"></td>
    </tr>
                   <tr>
                        <td>Code interne : </td>
                        <td><input name="NEtude" value="<%=NEtude%>" type="text" size="20"></td>
                   </tr>
              </table>
    <table>
    <tr>
         <td><input type="submit" name="action" value="valider"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    the page two:<%
    ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <% String[] listModalite= {"1erjet-HorsActivit&eacute;","1erjet-EnActivit&eacute;",
    "2iemejet-D&eacute;sinfection","2iemejet-Flambage","Ecoulement"};
    String [] CorrespModal={"1erjet-HorsActivite","1erjet-EnsActivite",
    "2iemejet-Desinfection","2iemejet-Flambage","Ecoulement"};
    String[] listExutoire={"Mitigeur","M&eacute;langeur","Robinet","Douchette",
    "Douche","Temporis&eacute;","Vanne"};
    String [] CorrespExu={"Mi","Me","Ro","Dt","Do","Tp","Va"};
    %>
    <html>
    <head>
    <title>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</title>
    </head>
    <body>      
    <center>
    <form action="<%= urlAction %>" method="post">
         <img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
    <h2>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</h2>
    <br>
    </center>
         <br><br>
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
    <td><input name="nomCentre" value="<%=nomCentre %>" type="text" size="20"></td>
    </tr>
              <tr>
                   <td>Code interne : </td>
                   <td><input name="NEtude" value="<%= NEtude %> " type="text" size="20"></td>
              </tr>
         </table>
         <!-- TABLE CONCERNANT LES PRELEVEMENTS -->
    <table>
         <%
         int m=1;
    while (resultSetIDPrelevement.next()){
              String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");
         String modalite="modalite"+m;
    String exutoire="exutoire"+m;
    String choix="choix"+m;
    %>                
              <tr>
                   <td><input name="idPrelevement" value="<%= idPrelevement %>" type="text" size="25"></td>
                   <td><input type="radio" name="<%=choix %>" value="Vl">Valider
                        <input type="radio" name="<%=choix %>" value="Ef">Effacer
                   </td>
                   <td><SELECT name="modalite" >     
              <% for (int i=0;i<listModalite.length;i++){ %>
                        <OPTION value="<%= CorrespModal[i] %>" ><%= listModalite[i] %></OPTION>
                   <% } %>                                                                                
                   </SELECT></td>
                   <td><SELECT name="exutoire" >     
                   <% for (int i=0;i<listExutoire.length;i++){ %>
                        <OPTION value="<%= CorrespExu[i] %>" ><%= listExutoire[i] %></OPTION>
                   <% } %>                                                                           
                   </SELECT></td>          
              </tr>
         <% m++;
         } %>          
    </table>
    <table>
         <tr>
         <td><input type="submit" name="action" value="testAffichage"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
         </table>
    </form>
    </body>
    </html>
    I really hope that i am enough clear !! Please , i really need help : why can't i recall the servlet ?? with this /null in my url ? why the urlAction in the page 2 (more complex ..) send null ?
    thanks in advance !                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    Hi Everybody !
    I have a big problem and i am front it since i am programming in servlet/jsp .
    The basic scheme in the tutorial is form.jsp => call and processing by the servlet => response.jsp .
    That i want to do is : simple form.jsp=> call and processing by the servlet (with method 1) => response1.jsp (which is a more complete form) => call and processing by the servlet (with method 2 which it is unlike method 1) => response2.jsp (final page).
    But i don't know how to do it : you don't understand with i want to make it ? so there is a simple example: a user want to know what he have eaten at a day:
    1)my first simple form.jsp: ask to the user his name and a date
    2)the response 1 and page 2 is return: it's a more complex and complete form (this page is well generate in my project )
    with this date and the name of the user, i question my database : "what this user have eaten at this date "?
    For example : at this date, he ate : chips at the aperitif and apple for dessert .
    The user must to complete the page 2 with more information (which have to be insert in the database):
    ex:
    had he ate this apple : in the kitchen, in the park, at his work ...?? (drop-down menu)
    had he ate this apple : baked, uncured ...?? (another drop-down menu)
    To resume: i want it's to recall the servlet with another button (with a name different in the servlet) to a specific method.
    in the first and simple form there is a button ONE that call the method1 of the servlet
    the servlet generate the page 2 (more complex and intermediate page)
    in this page 2 more information is asked to the user and there is a button TWO that call the method2 of the same servlet
    the final page (3) is generated by the servlet.
    So i success in the generation of the page 2 but when i click on the button TWO the controler (urlAction) send me null !!
    the call to the servlet is not done !
    some code:
    the servlet :
    public class ServletFichePrlvLEGactual extends HttpServlet{
         private String urlErreurs = null;
         private ArrayList erreursInitialisation = new ArrayList<String>();
         private String[] param�tres = {"urlFormulaire", "urlControleur","urlReponse","urlErreurs","urlReponseBis"};
         private Map params = new HashMap<String, String>();
         private ResultSet resultSetIDPrelevement;
    //     init
         @SuppressWarnings("unchecked")
         public void init() throws ServletException {
              // on r�cup�re les param�tres d'initialisation de la servlet
              ServletConfig config = getServletConfig();
              // on traite les autres param�tres d'initialisation
              String valeur = null;
              for (int i = 0; i < param�tres.length; i++) {
                   // valeur du param�tre
                   valeur = config.getInitParameter(param�tres);
                   // param�tre pr�sent ?
                   if (valeur == null) {
                        // on note l'erreur
                        erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
                   } else {
                        // on m�morise la valeur du param�tre
                        params.put(param�tres[i], valeur);
                   // l'url de la vue [erreurs] a un traitement particulier
                   urlErreurs = config.getInitParameter("urlErreurs");
                   if (urlErreurs == null) {
                        throw new ServletException(
                        "Le param�tre [urlErreurs] n'a pas �t� initialis�");
         @SuppressWarnings("unchecked")
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // on v�rifie comment s'est pass�e l'initialisation de la servlet
              if (erreursInitialisation.size() != 0) {
                   // on passe la main � la page d'erreurs
                   request.setAttribute("erreurs", erreursInitialisation);
                   getServletContext().getRequestDispatcher(urlErreurs).forward(
                             request, response);
                   // fin
                   return;
              // on r�cup�re la m�thode d'envoi de la requ�te
              String m�thode = request.getMethod().toLowerCase();
              // on r�cup�re l'action � ex�cuter
              String action = request.getParameter("action");
              // action ?
              if (action == null) {
                   action = "init";
              // ex�cution action
              if (m�thode.equals("get") && action.equals("init")) {
                   // d�marrage application
                   doInit(request, response);
                   return;
              if (m�thode.equals("post") && action.equals("valider")) {
                   try {
                        doInterrogationFormulaire(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              if (m�thode.equals("post") && action.equals("testAffichage")) {
                   // validation du formulaire de saisie
                   try {
                        dotestAffichage(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              // autres cas
              doInit(request, response);
         void doInit(HttpServletRequest request, HttpServletResponse response) throws ServletException,
         IOException {
    //          on r�cup�re la session de l'utilisateur
              HttpSession session = request.getSession(true);
              // on envoie le formulaire vide
              session.setAttribute("nomCentre", "");
              session.setAttribute("NEtude", "");
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                        request, response);
              return;
         void doInterrogationFormulaire(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres
              String nomCentre = (String) request.getParameter("nomCentre");
              String NEtude = (String) request.getParameter("NEtude");
              //puis on le stocke dans la session
              HttpSession session = request.getSession(true);
              session.setAttribute("nomCentre", nomCentre);
              session.setAttribute("NEtude", NEtude);
              Connexion com = new Connexion();
              try{
                   String query="SELECT idEtabl FROM Etablissement WHERE NomEtabl='"+nomCentre+"'";
                   ResultSet idCentre = com.ConnectAndQuestion(query);
                   idCentre.first();
                   String resulstatId=idCentre.getString("idEtabl");
                   String queryidPrelevement="SELECT idPrelevement FROM Etabl_Prlvmt where NEtude='"+NEtude+"' AND idEtabl='"+resulstatId+"'";
                   resultSetIDPrelevement=com.ConnectAndQuestion(queryidPrelevement);
                   if(resultSetIDPrelevement.next()!=false){
                        resultSetIDPrelevement.beforeFirst();
                        request.setAttribute("resultSetIDPrelevement", resultSetIDPrelevement);
                        getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(
                                  request, response);
                        com.close();
                        return;
                   else {     
                        getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                                  request, response);
                        com.close();
                        return;
              catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");
                   getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                             request, response);
                   return;          
         void dotestAffichage(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres d'int�ret
              ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
              Connexion updatePrlvmt= new Connexion();
              try{     
                   //serveur,login,pwd,database
                   updatePrlvmt.loadDriverAndConnect("127.0.0.1","3306","root","root","");
                   int k=1;
                   while (resultSetIDPrelevement.next()){
                        String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");               
                        if (request.getParameter("choix"+k) !="Vl"){                         
                             String champModalite=(String) request.getParameter("modalite"+k);
                             String champExutoire=(String) request.getParameter("exutoire"+k);
                             String queryUpdate="UPDATE PrelevLEG SET Modalite='"+champModalite +
                             "',Exutoire='"+champExutoire +
                             "',Temp='null',TempMax='null',Heure='null' WHERE idPrelevement='"+idPrelevement +
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                        if (request.getParameter("choix"+k) !="Ef"){
                             String queryUpdate="DELETE FROM PrelevLEG where idPrelevement='"+idPrelevement +"'";
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                   updatePrlvmt.close();
              }catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");     
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlReponseBis")).forward(request,
                        response);
              return;
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException {
              // on passe la main au GET
              doGet(request, response);
    the web.xml:<servlet>
         <servlet-name>FichePrlvLEGactual</servlet-name>
    <servlet-class>germande.LEG.ServletFichePrlvLEGactual</servlet-class>
         <init-param>
    <param-name>urlFormulaire</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formInterrogationActualPrlvmtLEG.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlErreurs</param-name>
    <param-value>/erreursRecap.biotech.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponse</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponseBis</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/respFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlControleur</param-name>
    <param-value>ServletFichePrlvLEGactual</param-value>
    </init-param>     
    </servlet>
    the first simple form:<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%
    // on r�cup�re les param�tres
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <html>
    <head>
    <title>Fiche R&eacute;sultats Legionelles - formulaire</title>
    </head>
    <body>
    <center>
    <h2>Fiche R&eacute;sultats Legionelles - formulaire</h2>
    <hr>
    <form action="<%= urlAction %>" method="post">
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
         <td><input name="nomCentre" value="<%=nomCentre%>" type="text" size="20"></td>
    </tr>
                   <tr>
                        <td>Code interne : </td>
                        <td><input name="NEtude" value="<%=NEtude%>" type="text" size="20"></td>
                   </tr>
              </table>
    <table>
    <tr>
         <td><input type="submit" name="action" value="valider"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    the page two:<%
    ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <% String[] listModalite= {"1erjet-HorsActivit&eacute;","1erjet-EnActivit&eacute;",
    "2iemejet-D&eacute;sinfection","2iemejet-Flambage","Ecoulement"};
    String [] CorrespModal={"1erjet-HorsActivite","1erjet-EnsActivite",
    "2iemejet-Desinfection","2iemejet-Flambage","Ecoulement"};
    String[] listExutoire={"Mitigeur","M&eacute;langeur","Robinet","Douchette",
    "Douche","Temporis&eacute;","Vanne"};
    String [] CorrespExu={"Mi","Me","Ro","Dt","Do","Tp","Va"};
    %>
    <html>
    <head>
    <title>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</title>
    </head>
    <body>      
    <center>
    <form action="<%= urlAction %>" method="post">
         <img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
    <h2>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</h2>
    <br>
    </center>
         <br><br>
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
    <td><input name="nomCentre" value="<%=nomCentre %>" type="text" size="20"></td>
    </tr>
              <tr>
                   <td>Code interne : </td>
                   <td><input name="NEtude" value="<%= NEtude %> " type="text" size="20"></td>
              </tr>
         </table>
         <!-- TABLE CONCERNANT LES PRELEVEMENTS -->
    <table>
         <%
         int m=1;
    while (resultSetIDPrelevement.next()){
              String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");
         String modalite="modalite"+m;
    String exutoire="exutoire"+m;
    String choix="choix"+m;
    %>                
              <tr>
                   <td><input name="idPrelevement" value="<%= idPrelevement %>" type="text" size="25"></td>
                   <td><input type="radio" name="<%=choix %>" value="Vl">Valider
                        <input type="radio" name="<%=choix %>" value="Ef">Effacer
                   </td>
                   <td><SELECT name="modalite" >     
              <% for (int i=0;i<listModalite.length;i++){ %>
                        <OPTION value="<%= CorrespModal[i] %>" ><%= listModalite[i] %></OPTION>
                   <% } %>                                                                                
                   </SELECT></td>
                   <td><SELECT name="exutoire" >     
                   <% for (int i=0;i<listExutoire.length;i++){ %>
                        <OPTION value="<%= CorrespExu[i] %>" ><%= listExutoire[i] %></OPTION>
                   <% } %>                                                                           
                   </SELECT></td>          
              </tr>
         <% m++;
         } %>          
    </table>
    <table>
         <tr>
         <td><input type="submit" name="action" value="testAffichage"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
         </table>
    </form>
    </body>
    </html>
    I really hope that i am enough clear !! Please , i really need help : why can't i recall the servlet ?? with this /null in my url ? why the urlAction in the page 2 (more complex ..) send null ?
    thanks in advance !                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

  • The Response Group application was unable to transfer the call to the configured destination and no fallback exists

    Hey,
    I get this error message when calling into an unassigned number which redirects to a response group:
    From user URI:
    sip:[email protected];gruu;opaque=srvr:Microsoft.Rtc.Applications.Acd:RS6nRGV9DlmpNsLtmz5qeQAA
    To user URI:
    0220198611;phone-context=DefaultProfile
    From user agent:
    RTCC/4.0.0.0 Response_Group_Service Announcement_Service
    Diagnostic header:
    26005; reason="The Response Group application was unable to transfer the call to the configured destination and no fallback exists."
    Interestingly "To user URI: 0220198611;phone-context=DefaultProfile" is the number off the caller not the destination. I wonder is this a bug? So is the response group trying to transfer to this number and failing because of course it doesnt exist?
    As you can see the below the number I am calling is not 0220198611: 
    From phone number: 0220198611;phone-context=DefaultProfile
    To phone number: +6493760053 From mediation server: onzlyncfe1.domain.co.nz To mediation server: From gateway: 192.168.100.70
    To gateway:
    Disconnected by: +6493760053
    Does the calling party's number have to be normalised? If so how can I do this because the global normailisation rules dont seem to apply
    in this situation. These rules do work when when calling into a users DDI. 
    Also to be clear....
    +6493760053 is an unassigned number which is setup to redirect to a response group.
    If I assign +6493760053 to a user then it works.
    Additionally this works perfectly when the gateway sends the call to our legacy 2007r2 mediation server then on to Lync. If the gateway sends the call directly to the co-located Lync mediation server I get the error described.
    I hope I make sense. If you are confused let me know :)
    Help is appreciated.
    Thanks,
    Andrew

    Hi ANdrew
    Kindly advise how you transfered the unassigned numbers to a specific user, i used the below command but it failled, the message displayed but the call never routed:
    New-CsAnnouncement -Parent service:ApplicationServer:LyncFE.squareone.local -Name "SQ unassigned number announcement" -TextToSpeechPrompt "You entered an invalid extinsion you will be forwarded to the operator" -Language "en-US" -TargetUri "sip:[email protected];user=phone"
    While [email protected] is the sip uri in my lync for the operator
    could you advise what is my issue?

  • SSRS in SharePoint2013:Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModule

    SSRS in SharePoint2013: There is a report in SharePoint and it contains a sub-report and the sub-report hyperlink. When I click the hyperlink to go to the sub-report, after >10min, I click the "Back to.." button
    on IE to go to the previous page. Then it catch the error as:
    Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
    Details: Error parsing near '
    <!DOCTYPE html PUB'.
    I am using SQL2012 and Sharpoint2013.

    Hi Alisa,
    Thanks for your reply, I changed the web.config, but the issue did not resolved. 
    I add the codes in two parts of the web.config as below, you can find in by keywords “aspnet:MaxHttpCollectionKeys”
    This issue can not reproduce on Chrome only occur on IE.
    So, do you have some details suggestion for me to fix it?
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <configuration>
    <configSections>
    <sectionGroup name="SharePoint">
    </sectionGroup>
    <location path="_layouts/15/TA_AppMonitoringDetails.aspx">
    <appSettings>
    <add key="ChartImageHandler" value="storage=memory;timeout=20" />
    </appSettings>
    </location>
    <location path="_layouts/15/ReportServer/RSViewerPage.aspx">
    <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="10000" />
    </appSettings>
    </location>
    <system.net>
    <defaultProxy />
    </system.net>
    <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="10000" />
    <add key="aspnet:RestrictXmlControls" value="true" />
    <add key="FeedCacheTime" value="300" />
    <add key="FeedPageUrl" value="/_layouts/15/feed.aspx?" />
    <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" />
    <add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    </appSettings>

  • Can we confirm the receipt of Servlet response by the client ?

    I wish to know whether the response of the servlet was recvd by the client or not ... and an acknowledgement message from client is not a possible option ...
    First priority wud be if this cud be done inside the servlet ...
    Second cud be if we cud write an independent agent of sorts which cud monitor delivery of responses from the (Tomcat service inside JBoss) server.... quick response will be highly appreciated ...
    Thanx and Regards
    Sandeep

    Well ... I found what I was looking for ... MultipartResponse API
    cos.jar at http://servlets.com/cos/

  • How can I call the jFreeChart to plot graph and get the result in Servlet?

    I want to use jFreeChart to plot time series graph, and then output the result in Servlet. How can I call the jFreeChart to plot graph and get back the result? Any source code for example? Thanks a lot!!

    Dave,
    ServletDemo1 and others were not in the distribution that I got (jfreechart-0.9.4). I found them under the premium demos somewhere in com/refinery/chart/demo/premium, but could not compile. They're complaining, among other things, about missing classes/packages com.refinery.date.SerialDate and com.refinery.ui. Am I using a wrong version of jfreechart?
    Thanks,
    -Alla
    There is a very simple servlet demo in the JFreeChart
    distribution:
    src/com/jrefinery/chart/demo/ServletDemo1.java
    This simply sends back an image to the browser.
    A second demo, which embeds the chart in an HTML page
    is:
    src/com/jrefinery/chart/demo/ServletDemo2.java
    src/com/jrefinery/chart/demo/ServletDemo2ChartGenerator
    java
    ...includes a time series chart as one of three
    options.
    Regards,
    Dave Gilbert
    JFreeChart Project Leader
    http://www.object-refinery.com/jfreechart/index.html

  • Getting the values from Servlet to Flex

    Hi EveryOne,
    i have a doubt ,i can send the parameters from flex to a
    servlet application ,and i can use these parameters there,
    so now can i get the values that are created in servlet to
    flex? response content in servlet is set to Xml not Html,
    any one please give me the idea or send me some code.
    *********Sorry For My English********

    I'm assuming you're writing the generated XML to the response
    object in your servlet.
    In the HTTPService class that you're using to send data to
    servlet, register a result event listener and once that event
    fires, you should get the results thru event.data property.
    If you think about it, this is exactly like you'll handle a
    AJAX call in your servlet and send data back only this time you've
    events instead of states.
    ATTA

  • How to attach XML file in the response of Web Services

    Hi
    I am new to the WEB SERVICE. this my requirement.
    I need to make a class file a web service. and i need to get data from the data base and attach it in the response. I need to use SOAP MEssaging for this. so how to call the service from the JSP and how to get the data from the response,Before that which technology i need to use for this requirement. Plz let me know how to accomplish this task. I have gone thur lot of tech stuff and i am confused a lot, what to use and how to use. Will any one help me out.
    Thanks
    Vidya

    Hey VP, thanks for replyng.
    I have read the codes from a book and havesome code for client. The server side is yet to be done....but I have problems in compiling them as I am Unable to import javax.xml.soap.*;
    This is basically a request to the Server asking it to find the match of the word "Mickey" from the XMLfile at the server...JAXRPC is involved(I Presume:) There are some supporting files.........hey But it doesn't compile only here. Hope it does in yrs
    *******The client..........**********
    * Client
    package com.aby.jwsdp.soap.client;//the package
    import javax.xml.messaging.URLEndpoint;
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Source;
    import javax.xml.transform.stream.StreamResult;
    import com.aby.jwsdp.soap.client.Fault;//supporting file
    import com.aby.jwsdp.soap.client.RequestMessage;//supporting file
    public class Client {
         static final string SERVICE_ENDPOINT="http://localhost:8080/chap/servlet/chap.RecieveServlet";
         public static void main(String args[]) {
              if(1!=args.length) {
                   System.err.println("Usage: java "+"com.aby.jwsdp.soap.client.Client <name>");
              } else {
                   new Client(args[0]);
         public Client(String name) {
              try{
                   URLEndpoint endpoint = new URLEndpoint(SERVICE_ENDPOINT);
                   SOAPConnectionFactory scf=SOAPConnectionFactory.newInstance();
                   SOAPConnection connection = scf.createConnection();
                   RequestMessage reqMsg = new RequestMessage();
                   reqMsg.setName(name);
                   SOAPMessage replySOAP = connection.call(reqMsq.getMessage(),endpoint);
                   if(Fault.hasFault(replySOAP)) {
                        Fault fault = new Fault(replySOAP);
                        System.err.println("Recieved SOAP Fault");
                        System.err.println("Fault Code: "+fault.getFaultCode());
                        System.err.println("Fault string: "+fault.getFaultString());
                        System.err.println("Fault detail: "+fault.getFaultDetail());
                   }else {
                        ResponseMessage respMsg = new ResponseMessage(replySOAP);
                        String responseValue = null;
                        try{
                             responseValue = respMsg.getValue();
                             System.out.println("Response: "+responseValue);
                        }catch(SchemaException e) {
                             System.err.println("Parsing error");
                   connection.close();
              }catch(EXception e) {
                   System.err.println(e/toString());
    /*@author Aby
    *Fault.java
    package com.aby.jwsdp.soap.client;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPFault;
    import javax.xml.soap.SOAPException;
    import javax.xml.soap.Detail;
    import javax.xml.soap.DetailEntry;
    import java.util.Iterator;
    public class Fault {
         protected SOAPFault soapFault;
         public Fault(SOAPMessage msg) throws SOAPException {
              SOAPPart soapPart = msg.getSOAPPart();
              SOAPEnvelope envelope = soapPart.getEnvelope();
              SOAPBody soapBody = envelope.getBody();
              soapFault = soapBody.getFault();
         public static boolean hasFault(SOAPMessage msg) throws SOAPException {
              SOAPPart soapPart = msg.getSOAPPart();
              SOAPEnvelope envelop = soapPart.getEnvelop();
              SOAPBody soapBody = envelop.getBody();
              return soapBody.hasFault();
         public String getFault() {
              return soapFault.getFaultCode();
         public String getFaultString() {
              return soapFault.getFaultString();
         public String getFaultDetail() {
              String ret = null;
              Detail detail = soapFault.getDetail();
              if(null!=detail) {
                   Iterator it = detail.getDetailEntries();
                   if(it.hasNext()) {
                        DetailEntry detEntry = (DetailEntry)it.next();
                   ret = detEntry.getValue();
              return ret;
    * RequestMessage.java
    package com.aby.jwsdp.soap.client;
    import com.aby.jwsdp.soap.client.Client;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPException;
    public class RequestMessage {
         protected SOAPMessage soapMessage = null;
         public RequestMessage()
         throws SOAPException {
              MessageFactory mf = MessageFactory.newInstance();
              soapMessage = mf.createMessage();
         public void setName(String name)
         throws SOAPException {
              SOAPPart soapPart = soapMessage.getSOAPPart();
              SOAPEnvelope envelope = soapPart.getEnvelope();
              SOAPBody body = envelope.getBody();
              SOAPElement requestElement;
              requestElement = body.addChildElement(envelope.createName("GetValueByName","myns","www.syngress.com/JWSDP/soap-example"));
              SOAPElement paramElement;
              paramElement = requestElement.addChildElement("name");
              paramElement.addTextNode(name);
         public SOAPMessage getMessage() {
              return soapMessage;
    check this out then we will see

  • Get the response instead of loading it in the browser

    HI.
    I would like to make a little program that would read the response of a request to a web page. I'm cant find how to do it. Everything i can foud call's the URL but loads th result in the initial browser window.
    Heres what I want :
    1- A friend as a servlet on a web site that does some maths with initial numbers intered in the window.
    2- I would like to make another servlet that would send some numbers to my friends servlet on the url(GET method).
    3- The all purpose is to be able to send a series of request on is servlet from a little list of numbers.
    I would appreciate any inputs. I've looked thru the javax.servlet.http librairis and java.net.
    Thanks for helping me.

    You don't need a servlet, an ordinary jaav program can do this. Have a look at the java.net package in the JDK docs. Something (totally untested!) like this should work;
    URL url = new URL("http://www.friendssite.com/friendsServlet?par1=val1&par2=val2&par3=val3");
    //par and val are as required by your friends serlet
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    con.setRequestMethod("GET");
    conn.connect();
    InputStream in = conn.getInputStream();
    //Now you can read the results from the InputStream
    HH

  • How to reset the response status and response header

    Dear Masters
    Actually we are using NTLM Authentication process to get the system login id for our web application. The problem which I am getting is after running the NTLM Authentication Code I am not able to call the action class. It is telling 400 Server error bad request. I am using Struts Dispatch Action Class. In Dispatch Action I will be passing a name (eg. method) as a parameter in struts-config.xml file and using that parameter I will be calling the respective method in the Action class. The problem which I am facing is after running the authentication code I am not able to fire the action class. It is telling the error in the console as "parameter named method is not found". Actually in NTLM Authentication code they are setiing the response status to www-authenticate,NTLM. If I reset the response status back to the normal form I think i will be able to fire the action class. Please give me a suggestion on how to reset the response status and response header back to the normal form. Any solution to this is appreciated. Please respond your reply as soon as possible. Thanks in advance.
    Regards
    Ramesh

    Hi,
    I think, a servlet filter is what you need. Please check the following URLs on how to go about creating a filter.
    http://dev2dev.bea.com/pub/a/2005/05/decorators.html
    http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html
    http://www.onjava.com/pub/a/onjava/2004/03/03/filters.html?page=1
    Cheers,
    vidyut

  • Servlets calls another servlet

    servlets calls another servlet ...how to do it ? whats the efficient way ?
    class myservlet extends HttpServlet
    // i want to call a servlet situated at another machine in the LAN whose, IP // 123.123.45.66 (say)
    the servlet which is situated in another machine
    remoteservlet extends HttpServlet
    doPost(...)
    how do i call ?
    few of the way i found by searching the forum.
    but i would like to know the good way in my situation.

    res.sendRedirect("LoginServlet?="+req.getRequestURI())
    i tested this. it does not work.
    my servlet wants to call another servlet which is
    active on IP xxx.ddd.ffff.zzz in the LAN .
    whats the way ?
    res.sendRedirect("http://xxx.ddd.ffff.zzz:<portnumber>/<context_name>/<servlet_regd_name">);The request and response objects are generated anew for that Servlet. There's no two ways about it, IMO.
    cheers,
    ram.

Maybe you are looking for

  • Unable to insert/add new item in LEGEND visual object

    I'm currently working in Solution manager and I tried to add a legend into one of my view of my web dynpro application. Unfortunatly, the Option 'INSERT ITEM' in the context menu is not visible/ not available. Is it because of Solution manager or is

  • WebService dataControls

    Hi, in model i create WEbServiceDataControl. On local i use ip like 195....... But when i deploy ma app on server - webServices must call from 172.... ip. My problem: i cant change ip for my dataControls. It work great on local or on server, i just w

  • Problem with cropped WPF content in an ElementHost

    I am displaying a WPF control inside an ElementHost. It works on most systems but on SOME the content gets cropped. Can anyone help me in the right direction with this?

  • Interactive in ALV

    Hi, Can u  guide me how to do Interactive reports in ALV with a sample Program code plz. Regards. CDREDDY.

  • Reformatting my soon-to-be-replaced Seagate HD..., Reformatting my soon-to-be-replaced Seagate HD...

    Sadly, I received the email that my beloved iMac has a faulty HD. So off to the Apple store this week it goes, but hopefully without any sensitive information on it. What's the best route for reformatting my HD so that the least information stays on