How to read an XML from a servlet?

Hi,
I'm just starting programming and now I have a problem I can't solve. I hope someone can help me.</p>
On the client side I have a xml report and a script wich sends to the server the information I've got from the report. In this case, the 'Poliza' value.
On the server-side I have a servlet. I try to get the parameters (from the URL or from the XML), but I don't have any response on the client side. I'm sure I'm doing something wrong but I can't find the solution for solving it.
I suppose there are two ways of solving the problem.
- Make an http connetion and send just the parametes on the URL? Does anyone know how to make it?
- Reading the XML on the servlet and extract the parameters the script sent. Does anyone know how to read it?
Thank you in advance
I attach part of the code.
CLIENT SIDE
<report....>
<field sortid="0" id="Poliza" inputtype="textbox" label="Poliza" rows="1" wide="false" required="false"/>
</report>
<script name="ValidacionOnlineValidation1" script="if (0 == 0){
var szURL="http://URLServer/vonline/vonline?Poliza="+Poliza.value;
var szUserAgent = "JoP-XML_Posting_v1.0";
var m_XML;
/* In the line below, construct a XML-document that contains all the information you need to send to the server*/
var szXML = "<?xml version=\"1.0\"?><data><objects><object name=\"Poliza\" value=\"123456789\"/></objects></data>";
/* Create an instance of the MS XML Document Object Model Parser*/
m_XML= new ActiveXObject("Microsoft.XMLDOM");
m_XML.validateOnParse=true;                                                                                                         
var bLoadResult = m_XML.loadXML(szXML);
if (bLoadResult==true) {
  /*Instance of the transport object, method,...*/
  var m_HttpReq = new ActiveXObject("Pocket.HTTP");
  m_HttpReq.method = "GET";
  m_HttpReq.Headers.create("Content-Type", "text/xml");
  m_HttpReq.Headers.find ("User-Agent").Value = szUserAgent;
  m_HttpReq.timeout = 150000;
  /*Do the actual post of the data*/
  var m_HttpResponse = m_HttpReq.GetResponse(szURL,m_XML.xml);
  if (m_HttpResponse.statusCode==200) {...}
SERVER SIDE
protected void processRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
     String Error="";
     String MSG = "";
     response.setContentType("text/html");
     PrintWriter out1 = response.getWriter();
     Enumeration arrayparametros = request.getParameterNames();
     for (;arrayparametros.hasMoreElements();){
          String parametro = (String)arrayparametros.nextElement();
          String valorparametro = request.getParameter(parametro);
          if (parametro.equals("Poliza")){
               vonlineLogica logica = new vonlineLogica();
               LOGS ="on";
               Respuesta respuesta = logica.procesarSolicitud(request,valorparametro);
               Error = Respuesta.getError();
               MSG = Respuesta.getMensaje();
          else{          
               Error = parametro; MSG = valorparametro;
               String[] values = request.getParameterValues(parametro);
     out1.println("Result: " + Error + " / " + MSG);
     out1.close();                    
}

Thanks by your help Shanu.
Nevertheless, finally I tryed the easiest way (pass the parameter with 'GET'). Moreover I found why my code wasn't working. It was a fool thing. I though PDA connect throught a proxy, but it wasn't true. Whatever.
Regards.
FSG.
The final script on the xml-report is:
<report type="Validacion Online" required="false" multiple="false" attachments="false" scriptref="store://this/reportdef/script[@name='ValidacionOnlineValidation1']">
     <field sortid="0" id="Poliza" inputtype="textbox" label="Poliza" rows="1" wide="false" required="false"/>
</report>
<script name="ValidacionOnlineValidation1" script="if (0 == 0)
var szURL="http://URL/vonline/vonline?parameter1=";+Poliza.value;                         
var m_HttpReq = new ActiveXObject("Pocket.HTTP");                                             m_HttpReq.timeout = 15000;
var m_HttpResponse = m_HttpReq.GetResponse(szURL,"");
window.alert(m_HttpResponse.string);
if (m_HttpResponse.statusCode==200)  {....}
else {....}

Similar Messages

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to read an xml file from headers

    Hi ,
    I am not getting how to read an xml file sent by client device in header to server.
    Thankx.

    There is a getHeader() in HttpServletRequest interface
    String locationURL=request.getHeader("Location");If URL of your file was set in Location attribute of header.
    Edited by: ngpgeeta on Dec 19, 2008 8:03 AM

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

  • How to read Group ID from Value Mapping Context in Cache Monitoring ?

    Hi friends,
        In RWB --> Cache Monitoring --> Integration Server (Java) -> (Search for Value Mapping Groups) in this each item is identified by Value Mapping Group (GroupID, Context, Identifier/Agency, Identifier/Scheme). Either we create Value Mapping Table in ID or replicate value mapping data directly from text file/SAP table etc., in run time cache, data will be identified in this manner.
        Now, our requirement is to delete a record the Cache for a particular context. Two operations provided by XI one is 'Delete' and another one is 'DeleteGroup'. When we use either of this, we should know GroupID. Suppose, I replicated some large amount of data from my text file in Runtime Cache. Value Mapping Table is like that IN --> India, US --> USA, AU --> Australia, EG --> Egypt. Now, I am required to write a program to get the input country code from user which is going to delete in the value mapping table like IN/AU....  For this, what logic we should follow in the program is, First we scan the value mapping table and find the record (country code)  which is match with the input. Then find the GUID value for this record. Now we use the DeleteGroup Operation and pass this GUID and then delete the record.
        So, in essence, how to read the GUID from value mapping context.
        Friends, Kindly help me to do this.
    Thanks in advance.
    Jegatheeswaran P.

    Did you get the way to read group id?

  • How 2 read two files from 2 diff. directories, using single adapter

    How 2 read two files from 2 diff. directories in same system, using single file adapter.

    you can use advanced selection for source file
    see
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm

  • How to read a mail from sap inbox thru abap code?

    how to read a mail from sap INBOX thru abap code? can anyone tell me the technical approach? I NEED TO READ A MAIL and then need to pass the parameters to a bapi.
    Message was edited by:
            shahid mohammed syed

    Hi SSM,
    Did you manage to have your program working? I also have same requirement. I tried standard FM and BAPI but I always encounter authorization error when I tried accessing other user's mail. Thanks.
    Regards,
    Ryan

  • How to read data directly from clusters

    hi all,
    how to read data directly from clusters
    Thanx in advance,
    amruta.

    Using macro:
    RP-IMP-C2-B2.
    RP-IMP-C2-B1.
    RP-IMP-C2-ZL.
    ....etc.
    For TM cluster, U also can use BAPIs like HR_TIME_RESULTS_GET
    More details see SAP HR course 350(HR Programming)

  • How to read appended objects from file with ObjectInputStream?

    Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
    What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
    The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
    I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
    import java.io.*;
    class Fio
         public static void main(String[] args)
              try
                   if (args[0].equals("w"))
                        FileOutputStream fos = new FileOutputStream(args[1], true);
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        for (int i = 2; i < args.length ; i++)
                             oos.writeObject(args);
                        fos.close();
                   else if (args[0].equals("r"))
                        FileInputStream fis = new FileInputStream(args[1]);
                        ObjectInputStream ois = new ObjectInputStream(fis);
                        for (int i = 0; i < fis.available(); i++)
                             System.out.println((String)ois.readObject());
                        fis.close();
                   else
                        System.out.println("Wrong args!");
              catch (IndexOutOfBoundsException exc)
                   System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
              catch (IOException exc)
                   System.out.println("I/O exception appeard!");
              catch (ClassNotFoundException exc)
                   System.out.println("Can not find the needed class");

    How to read appended objects from file with ObjectInputStream? The short answer is you can't.
    The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
    Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
    Not trivial, but that's how you'd do it.

  • How to read a string from file & assign the val to a variable in batch file

    Hi,
    How to read a string from a file and assign the value to a variable then return the value to the screen in windows batch file?
    Any suggestions?
    thanks.

    Unless this is a homework question then I don't see the purpose of doing this, but....
    You should be looking a the supplied package utl_file to get the string out of the file, dbms_output to display the string and then google windows batch/command files calling sqlplus to execute your program.
    Andre

  • How to read a table from one host to other host

    Hi Everybody,
    How to read a table from one host to other host.
    For Example,
    a/a@abcd - host 1
    b/b@xyz - host 2
    suppose im having a table called emp in a/a@abcd
    i want to read the table emp in b/b@xyz
    how to do this.??
    I know that we have to create a dblink...after that how to proceed.
    Plz help..
    Thanks in Advance,
    Gita

    connected as scott/tiger@test
    SQL>
    CREATE DATABASE LINK local
    CONNECT TO admin IDENTIFIED BY pinnet
    USING 'pinnet';
    Database link created.
    sql>
    select count(*) from
    users@local;
    COUNT(*) 
    16
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to read some images from file system with webdynpro for abap?

    Hi,experts,
    I want to finish webdynpro for abap program to read some photos from file system. I may make MIMES in the webdynpro component and create photos in the MIMES, but my boss doesn't agree with me using this way. He wish me read these photos from file system.
    How to read some images from file system with webdynpro for abap?
    Thanks a lot!

    Hello Tao,
    The parameter
       icm/HTTP/file_access_<xx>
    may help you to access the pictures without any db-access.
    The following two links may help you to understand the other possibilities as well.
    The threads are covering BSP, but it should be useful for WebDynpro as well.
    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
    http://help.sap.com/saphelp_sm40/helpdata/de/c4/87153a1a5b4c2de10000000a114084/content.htm
    Best regards
    Christian

  • How to run db.xml from ORPOS 13.4 version on standalone

    Hi All,
    How to run db.xml from ORPOS 13.4, We dont have ORBO.
    Thanks & Regards
    GM

    Go to the location where your installer is residing and execute the following command:
    install.cmd ant install-database
    Regards,
    Uttam Kumar

  • How to read bytes(image) from a server ?how to display image after read byt

    How to read bytes(image) from a server ?how to display image after reading bytes?
    i have tried coding tis , but i couldnt get the image to be display:
    BufferedInputStream in1=new BufferedInputStream(kkSocket.getInputStream());
    int length1;
    byte [] data=new byte[1048576];
    if((length1=in1.read(data))!=-1){
    System.out.println("???");
    }System.out.println("length "+length1);
    Integer inter=new Integer(length1);
    byte d=inter.byteValue();

    didn't I tell you about using javax.imageio.ImageIO.read(InputStream) in another thread?

Maybe you are looking for

  • Mini Display to VGA adapter doesn't fit

    I have an older(2008) MacBook and the MIni display to VGA adapter I purchased doesn't fit my book. Is there one that I can buy that will fit?

  • No longer safe to remove iPod after updating (synching)

    I'm using iTunes 7 on XP Pro. AMD Athlon 64. 4G 60-gig iPod (color). "Enable Disk Use" is NOT checked, but my iPod now shows up as a Removable Disk in XP. And after synching, iTunes says "iPod update is complete" but no longer tells me it's safe to r

  • Navigational attribute data not visible in BEx Report

    Hello All, I am facing following problem in one of my BEx reports: I am fetching data from an ODS. With other columns of ODS,  I have also to show few navigational attributes( which are master data of some info-object) . In report the corresponding d

  • Error  "No conversion found for EA to KG"

    Hi, I am facing an error like "No conversion found for EA to KG" at the time of GR. Inputs: In Mat Master Base UOM is Gram,Order Unit is KG and Conversion(1Kg=1000G) is maintained in Additional Data. Purchase Order created with KG as both Order Unit

  • Networking from iMac to Windows laptops

    I have an iMac and two Windows Vista laptops. Before I installed Leopard I could see both laptops on my wireless network and get into both for transferring files etc. Now I cannot. I can sometimes (but not always) see the laptops in Finder- Network b