How to return URL of servlet path ?

Hello,
I want to return the URL of current servlet path (such as "http://www.mydomain.com:888/servlet"). How can I do that ?
thanks in advance...

Hi danisment,
Checkout the API for javax.servlet.http.HttpServletRequest Interface in which you have the methods to get path information.
Use
request.getServletPath();Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.
If you want the entire URL,
use request.getRequestURL(); returns the StringBuffer
The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters
Hope this will throw some light for you problem.
Thanks,
Sanath Kumar

Similar Messages

  • How to redirect url in servlet?

    in servlet, i want to redirect page to a url which not in same container, and send to some information to this url, what shall i do?
    thanks.

    duffymo's solution should do it, then.
    You could build on top of that and send serialized data (I'm assuming your data is serializable) over the wire to the other server using an HttpUrlConnection and ObjectOutputStream's writeObject(), and read it at the other end with ObjectInputStream's readObject(). For example for the write operation :
    URL url = new URL(other_server_url);
    HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
    // after setting urlcon attributes like requestMethod to POST etc...
    ObjectOutputStream out = new ObjectOutputStream(urlcon.getOutputStream());
    // now write the data, then flush & close the connection
    ...If the amount if data to transfer is quite large, you could again build on top of the above and use CompressedSerialization :
    http://robowiki.dyndns.org/perl/robowiki?CompressedSerialization

  • How to return arraylist  from servlet to midlet

    hi everybody !
    Can anybody help me in solving this problem.
    I am working on an application in which I am using Midlet to servlet
    communication.
    In this I am sending username and password from Midlet to servlet .
    At server side servlet check the authentication and send the corresponding
    contactlist of user from database to the MIDLet.
    On Midlet this list should appear list-wise.
    please tell me that how can I achieve this....
    Thanks in Advanced....
    bhagwat

    Hi,
    Can u say how to lock folder without using any tools??
    If i click on folder,it should ask for password.if the entered value is valid,the folder should open....
    Can u provide code for this????
    Is there any need to interact with operating system???
    Please reply me soon..
    Thanks in advance...
    Vinoda

  • How to call two different servlet-url in the same application

    Hi,
    I want to call, consecutively these methods in my application.
    response.sendRedirect(servlet-url1)
    reponse.sendRedirect(servlet-url2)
    but the second method dont answer,
    I think, the first method redirect s with response ,
    but how to call two different servlet ?
    thanks

    if you call the first redirect, the servlet is getting aborted, so you can redirect to the first servlet, working the stuff in it, and then in the second servlet you can redirect to the third servlet

  • How do i run a servlet??????

    running servlets:i downloaded jsdk but how do i run a servlet? i got the error
    C:\WINDOWS\Desktop>javac HTTPGetServlet.java
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
    ain
    when i tried to run my servlet, please help
    thanks

    As mentioned in another post in the thread, servlets run from within a web server that has pre-loaded the jvm and serves web requests. Often they are called 'sevlet containers' as they act like a wrapper program for the actual vm. Tomcat is such a web server, quite a popular one for running servlets, and is considered the reference implementation for a sevlet/jsp server. you can read up on it at...
    http://jakarta.apache.org/tomcat/index.html
    To get you started, this is what i did to set up tomcat. Im using RedHat Linux at home, so this may differ to what you have to do initially.
    First, make sure you have at least the jsdk and jsdk ee installed and the appropiate JAVA_HOME and J2EE_HOME environment variables set.
    I am using the Apache web server to handle web page requests on my box. If the request is for a context containing a servlet or jsp file (context is a tomcat term for a particular location or path in the url) then apache passes the request to tomcat via a apache module and a special protocol. Tomcat then runs the .class file or .jsp file, returns the output to apache which then returns the output back to the browser. So initially you should set up and have the apache web server running.
    Next download and install the jserv or tomcat module for apache, which apache uses to communicate with tomcat via a special protocol, and the tomcat rpms from...
    http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/rpms/
    ...Im using 3.2.3 which works fine. you may try the later versions if you like.
    Install the tomcat rpms. They should dump a whole lot of stuff in a /var/tomcat directry, including some nice sample and admin apps. if you had downloaded and installed the tomcat-manuals rpm you can find lots of helpful information in the /usr/doc/tomcat-{your version here}/ directry. This is what you should probably read through now!
    Once that is done, its simply a matter of adding a reference in your httpd.conf file to the tomcat.conf file in the tomcat/conf dir (if you want to have complete control over the tomcat module and contexts) or tomcat-apache.conf (in the same directry) if youd like tomcat to handel its own configuration of apache. something like...
    include /var/tomcat/conf/tomcat.conf
    ...should do.
    then run tomcat start (in /usr/bin/) and apache and away you go. You should be able to point your browser to your.server.com/admin/ and get the tomcat admin tools. This allows you to add view and delete contexts to your server (say for separating different server-side applications). your.server.com/examples/ has some nice stuff as well.
    Hope this helps. I warn you im not an expert and haven't looked at this stuff for some time. I probably have something wrong so please, experts, if you see something stuffed up let us know.

  • Have a problem in getting the servlet path

    hi
    i wanna get the complete path to my servlet folder in TomcatServer
    like http://localhost:8084/Test can anyone tell me how can i get it plz.

    try ServletContext.getRealPath
    Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem would be served by a request for "http://host/contextPath/index.html", where contextPath is the context path of this ServletContext.
    The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators. This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).

  • Return url for the current page

    Hi,
    I would like to know how to return the url for the current page?

    These are my preferred choices:
    request.getRequestURI() will give you the relative path from root. For example:
    /mypages/thepageIamon.jsp
    request.getRequestURL().toString() will give you the full path. For example:
    http://www.mysite.com/mypages/thepageIamon.jsp
    Hope this helps.

  • FRM-92052 error... unable to connect to server URL /forms/servlet;

    Hi all.
    I'm on forms 11g 11.1.2.1.0
    I'm configuring my form and when I try to run it I have this error:
    FRM-92052: unable to connect to server at URL /forms/servlet;
    I have start up weblogic server and everything is ok.
    When I try to run my form I have the error.
    How can I solve it?
    Thanks all for collaboration,
    Fabrizio

    I open my log file and I copy here error section:
    java.lang.NoSuchMethodError: oracle/forms/net/ConnectionException.<init>(ILjava/lang/String;Ljava/lang/Throwable;)V
         at oracle.forms.servlet.BaseServlet.getConnectionException(Unknown Source)
         at oracle.forms.servlet.BaseServlet.logException(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getRunformSession(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getInfo(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.doGet(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.access$100(Unknown Source)
         at oracle.forms.servlet.ListenerServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    >
    ####<5-feb-2013 14.42.40 CET> <Notice> <Diagnostics> <missuri377> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <2e61ea05cba29510:6243aa29:13caa961585:-8000-0000000000000024> <1360071760720> <BEA-320068> <Watch 'UncheckedException' with severity 'Notice' on server 'AdminServer' has triggered at 5-feb-2013 14.42.40 CET. Notification details:
    WatchRuleType: Log
    WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'WL-101020') OR (MSGID = 'WL-101017') OR (MSGID = 'WL-000802') OR (MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802'))
    WatchData: DATE = 5-feb-2013 14.42.40 CET SERVER = AdminServer MESSAGE = [ServletContext@6140131[app:formsapp module:forms path:/forms spec-version:2.5 version:11.1.2]] Root cause of ServletException.
    java.lang.NoSuchMethodError: oracle/forms/net/ConnectionException.<init>(ILjava/lang/String;Ljava/lang/Throwable;)V
         at oracle.forms.servlet.BaseServlet.getConnectionException(Unknown Source)
         at oracle.forms.servlet.BaseServlet.logException(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getRunformSession(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getInfo(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.doGet(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.access$100(Unknown Source)
         at oracle.forms.servlet.ListenerServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    SUBSYSTEM = HTTP USERID = <WLS Kernel> SEVERITY = Error THREAD = [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-101017 MACHINE = missuri377 TXID = CONTEXTID = 2e61ea05cba29510:6243aa29:13caa961585:-8000-0000000000000022 TIMESTAMP = 1360071760564
    WatchAlarmType: AutomaticReset
    WatchAlarmResetPeriod: 30000
    >
    How can I solve my problem?
    Thanks all for collaboration,
    Fabrizio

  • How can i zip without full path?

    I zip a file with this servlet, but when i unzip the file, it save my file with a full path... how can i do? thanks
    CODE
    import java.io.*;
    import java.util.zip.*;
    public class ZIPFILE
    public String DOPOSTPROCESS(String filename)
    FileOutputStream fileout = null;
    byte[] buf = new byte[1024];
    try
    File f1 = new File(filename);
    File f2 = new File(filename+".zip");
    String fileoutname=filename + ".zip";
    fileout = new FileOutputStream(fileoutname,false);
    ZipOutputStream out = new ZipOutputStream(fileout);
    // Compress the files
    FileInputStream in = new FileInputStream(filename);
    // Add ZIP entry to output stream.
    out.putNextEntry(new ZipEntry(filename));
    // Transfer bytes from the file to the ZIP file
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    // Complete the entry
    out.closeEntry();
    in.close();
    // Complete the ZIP file
    out.close();
    f1.delete();
    f2.renameTo(f1);
    catch (IOException e)
    try
    catch(Exception e1)
    return("Errore CR2CRLF "+e);
    return null;
    }

    If the path name consists of one or several directories and then by the file name, you could use only the file name portion for the insertion into the zip archive.

  • How to return a profile in Game Center. where you want to enter the old nikneim?

    How to return a profile in Game Center. where you want to enter the old nikneim?

    It's not actually round.  It is slight flattened vertically.
    Anyway...
    I have an Action that places guides at 50% (50pc) vertically and horizontally to give me the exact center of an image file, or you place them manually with View > New Guide.
    After doing that I would place the circular select from that center point using Shift and Alt (Opt) and get it more or less where I wanted it.  Then change the selection into a work path.
    You can use Free Transform to reshape and position that work path by selecting it in the Paths panel.
    Then place your text, and if you still need to fine tune, use Free Transform again, but on the Type layer.
    You could also use Free Transform to reshape the BG graphic to make it round.

  • [UIX] How To: Return multiple values from a LOV

    Hi gang
    I've been receiving a number of queries via email on how to return multiple items from a LOV using UIX thanks to earlier posts of mine on OTN. I'm unfortunately aware my previous posts on this are not that clear thanks to the nature of the forums Q&A type approach. So I thought I'd write one clear post, and then direct any queries to it from now on to save me time.
    Following is my solution to this problem. Please note it's just one method of many in skinning a cat. It's my understanding via chatting to Oracle employees that LOVs are to be changed in a future release of JDeveloper to be more like Oracle Forms LOVs, so my skinning skills may be rather bloody & crude very soon (already?).
    I'll base my example on the hr schema supplied with the standard RDBMS install.
    Say we have an UIX input-form screen to modify an employees record. The employees record has a department_id field and a fk to the departments table. Our requirement is to build a LOV for the department_id field such that we can link the employees record to any department_id in the database. In turn we want the department_name shown on the employees input form, so this must be returned via the LOV too.
    To meet this requirement follow these steps:
    1) In your ADF BC model project, create 2 EOs for employees and departments.
    2) Also in your model, create 2 VOs for the same EOs.
    3) Open your employees VO and create a new attribute DepartmentName. Check “selected in query”. In expressions type “(SELECT dept.department_name FROM departments dept WHERE dept.department_id = employees.department_id)”. Check Updateable “always”.
    4) Create a new empty UIX page in your ViewController project called editEmployees.uix.
    5) From the data control palette, drag and drop EmployeesView1 as an input-form. Notice that the new field DepartmentName is also included in the input-form.
    6) As the DepartmentName will be populated either from querying existing employees records, or via the LOV, disable the field as the user should not have the ability to edit it.
    7) Select the DepartmentId field and delete it. In the UI Model window delete the DepartmentId binding.
    8) From the data controls palette, drag and drop the DepartmentId field as a messageLovInput onto your page. Note in your application navigator a new UIX page lovWindow0.uix (or similar) has been created for you.
    9) While the lovWindow0.uix is still in italics (before you save it), rename the file to departmentsLov.uix.
    10) Back in your editEmployees.uix page, your messageLovInput source will look like the following:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="${bindings.DepartmentId.path}"
        destination="lovWindow0.uix"/>Change it to be:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="DepartmentId"
        destination="departmentsLov.uix"
        partialRenderMode="multiple"
        partialTargets="_uixState DepartmentName"/>11) Also change your DepartmentName source to look like the following:
    <messageTextInput
        id=”DepartmentName”
        model="${bindings.DepartmentName}"
        columns="10"
        disabled="true"/>12) Open your departmentsLov.uix page.
    13) In the data control palette, drag and drop the DepartmentId field of the DepartmentView1 as a LovTable into the Results area on your page.
    14) Notice in the UI Model window that the 3 binding controls have been created for you, an iterator, a range and a binding for DepartmentId.
    15) Right click on the DepartmentsLovUIModel node in the UI Model window, then create binding, display, and finally attribute. The attribute binding editor will pop up. In the select-an-iterator drop down select the DepartmentsView1Iterator. Now select DepartmentName in the attribute list and then the ok button.
    16) Note in the UI Model you now have a new binding called DCDefaultControl. Select this, and in the property palette change the Id to DepartmentName.
    17) View the LOV page’s source, and change the lovUpdate event as follows:
    <event name="lovSelect">
        <compound>
            <set value="${bindings.DepartmentId.inputValue}" target="${sessionScope}" property="MyAppDepartmentId" />
            <set value="${bindings.DepartmentName.inputValue}" target="${sessionScope}" property="MyAppDepartmentName" />
        </compound>
    </event>18) Return to editEmployees.uix source, and modify the lovUpdate event to look as follows:
    <event name="lovUpdate">
        <compound>
            <set value="${sessionScope.MyAppDepartmentId}" target="${bindings.DepartmentId}" property="inputValue"/>
            <set value="${sessionScope.MyAppDepartmentName}" target="${bindings.DepartmentName}" property="inputValue"/>     
        </compound>
    </event>That’s it. Now when you select a value in your LOV, it will return 2 (multiple!) values.
    A couple things to note:
    1) In the messageLovInput id field we don’t use the “.path” notation. This is mechanism for returning 1 value from the LOV and is useless for us.
    2) Again in the messageLovInput we supply “_uixState” as an entry in the partialTargets.
    3) We are relying on partial-page-refresh functionality to update multiple items on the screen.
    I’m not going to take the time out to explain these 3 points, but it’s worthwhile you learning more about them, especially the last 2, as a separate exercise.
    One other useful thing to do is, in your messageLovInput, include as a last entry in the partialTargets list “MessageBox”. In turn locate the messageBox control on your page (if any), and supply an id=”MessageBox”. This will allow the LOV to place any errors raised in the MessageBox and show them to the user.
    I hope this works for you :)
    Cheers,
    CM.

    Thanks Chris,
    It took me some time to find the information I needed, how to use return multiple values from a LOV popup window, then I found your post and all problems were solved. Its working perfectly, well, almost perfectly.
    Im always fighting with ADF-UIX, it never does the thing that I expect it to do, I guess its because I have a hard time letting go of the total control you have as a developer and let the framework take care of a few things.
    Anyway, I'm using your example to fill 5 fields at once, one of the fields being a messageChoice (a list with countries) with a LOV to a lookup table (id , country).
    I return the countryId from the popup LOV window, that works great, but it doesn't set the correct value in my messageChoice . I think its because its using the CountryId for the listbox index.
    So how can I select the correct value inside my messageChoice? Come to think of it, I dont realy think its LOV related...
    Can someone help me out out here?
    Kind regards
    Ido

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • How to find the local Weblogic path

    If I have multiple Web sites running under WebLogic, how can I get the
              real path in my Servlet for one of the sites? getWorkingPath()?
              Thanks
              From Tom Gerber
              

              out.println("Real Path ", req.getRealPath(req.getServletPath( )))
              PS : Here req is HttpServletRequest's object
              Thanks
              Kumar
              kagg wrote:
              > If I have multiple Web sites running under WebLogic, how can I get the
              > real path in my Servlet for one of the sites? getWorkingPath()?
              >
              > Thanks
              >
              > --
              > From Tom Gerber
              

  • How to call url from abap in background

    Hi,
    I could open url but it opens browser window
    i saw several threads on how to cal url in background but no good answer
    kindly help
    thanks
    B

    Hi,
    Try the following (primitive) example, it calls an url and display the result on screen.
    Hope this will help you.
    <pre>
    REPORT  test.
          CLASS lcx_http_client DEFINITION
          Minimal Error Handling
    CLASS lcx_http_client DEFINITION INHERITING FROM cx_static_check.
      PUBLIC SECTION.
        INTERFACES:
          if_t100_message.
        DATA:
           mv_method TYPE string,                               "#EC NEEDED
           mv_subrc  TYPE i.                                    "#EC NEEDED
        METHODS:
          constructor
            IMPORTING iv_method TYPE string  OPTIONAL
                      iv_subrc  TYPE i       OPTIONAL
                      iv_msgid  TYPE symsgid DEFAULT '00'
                      iv_msgno  TYPE i       DEFAULT 162.
    ENDCLASS.                    "lcx_http_client DEFINITION
          CLASS lcx_http_client IMPLEMENTATION
    CLASS lcx_http_client IMPLEMENTATION.
      METHOD constructor.
        super->constructor( ).
        mv_method = iv_method.
        mv_subrc  = iv_subrc.
        if_t100_message~t100key-msgid = iv_msgid.
        if_t100_message~t100key-msgno = iv_msgno.
        if_t100_message~t100key-attr1 = 'MV_METHOD'.
        if_t100_message~t100key-attr2 = 'MV_SUBRC'.
      ENDMETHOD.                    "constructor
    ENDCLASS.                    "lcx_http_client IMPLEMENTATION
          CLASS lcl_http_client DEFINITION
          Facade for if_http_client
    CLASS lcl_http_client DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          get_http_client_by_url
            IMPORTING iv_url           TYPE string
                      iv_proxy_host    TYPE string OPTIONAL
                      iv_proxy_service TYPE string OPTIONAL
                      PREFERRED PARAMETER iv_url
            RETURNING value(ro_http_client) TYPE REF TO lcl_http_client
            RAISING lcx_http_client.
        DATA:
          mr_http_client TYPE REF TO if_http_client.
        METHODS:
          send
            RAISING lcx_http_client,
          receive
            RAISING lcx_http_client,
          close
            RAISING lcx_http_client,
          get_response_header_fields
            RETURNING value(rt_fields) TYPE tihttpnvp,
          get_response_cdata
            RETURNING value(rv_data) TYPE string.
    ENDCLASS.                    "lcl_http_client DEFINITION
          CLASS lcl_http_client IMPLEMENTATION
    CLASS lcl_http_client IMPLEMENTATION.
      METHOD get_http_client_by_url.
        DATA: lv_subrc TYPE sysubrc.
        CREATE OBJECT ro_http_client.
        cl_http_client=>create_by_url( EXPORTING url                 = iv_url
                                                 proxy_host          = iv_proxy_host
                                                 proxy_service       = iv_proxy_service
                                       IMPORTING client              = ro_http_client->mr_http_client
                                       EXCEPTIONS argument_not_found = 1
                                                  plugin_not_active  = 2
                                                  internal_error     = 3
                                                  OTHERS             = 999 ).
        CHECK sy-subrc <> 0.
        lv_subrc = sy-subrc.
        RAISE EXCEPTION TYPE lcx_http_client EXPORTING iv_method = 'GET_HTTP_CLIENT_BY_URL' iv_subrc = lv_subrc.
      ENDMETHOD.                    "get_http_client_by_url
      METHOD send.
        DATA: lv_subrc TYPE sysubrc.
        mr_http_client->send( EXCEPTIONS http_communication_failure = 5
                                         http_invalid_state         = 6
                                         http_processing_failed     = 7
                                         http_invalid_timeout       = 8
                                         OTHERS                     = 999 ).
        CHECK sy-subrc <> 0.
        lv_subrc = sy-subrc.
        RAISE EXCEPTION TYPE lcx_http_client EXPORTING iv_method = 'SEND' iv_subrc = lv_subrc.
      ENDMETHOD.                    "send
      METHOD close.
        DATA: lv_subrc TYPE sysubrc.
        CALL METHOD mr_http_client->close
          EXCEPTIONS
            http_invalid_state = 10
            OTHERS             = 999.
        CHECK sy-subrc <> 0.
        lv_subrc = sy-subrc.
        RAISE EXCEPTION TYPE lcx_http_client EXPORTING iv_method = 'CLOSE' iv_subrc = lv_subrc.
      ENDMETHOD.                    "close
      METHOD receive.
        DATA: lv_subrc TYPE sysubrc.
        mr_http_client->receive( EXCEPTIONS http_communication_failure = 9
                                            http_invalid_state         = 10
                                            http_processing_failed     = 11
                                            OTHERS                     = 999 ).
        CHECK sy-subrc <> 0.
        lv_subrc = sy-subrc.
        RAISE EXCEPTION TYPE lcx_http_client EXPORTING iv_method = 'RECEIVE' iv_subrc = lv_subrc.
      ENDMETHOD.                    "receive
      METHOD get_response_header_fields.
        mr_http_client->response->get_header_fields( CHANGING fields = rt_fields ).
      ENDMETHOD.                    "get_response_header_fields
      METHOD get_response_cdata.
        rv_data = mr_http_client->response->get_cdata( ).
      ENDMETHOD.                    "get_response_cdata
    ENDCLASS.                    "lcl_http_client IMPLEMENTATION
    PARAMETERS: p_url   TYPE string DEFAULT 'http://www.google.com' LOWER CASE,
                p_phost TYPE string DEFAULT 'your_proxy_here'       LOWER CASE,
                p_pserv TYPE string DEFAULT '8080'                  LOWER CASE.
    *===================================================================================
    START-OF-SELECTION.
      TRY .
          DATA: gt_data          TYPE string_table,
                gv_data          TYPE string,
                gr_http_client   TYPE REF TO lcl_http_client,
                go_cx            TYPE REF TO lcx_http_client.
          "Initialize the http client
          gr_http_client =
            lcl_http_client=>get_http_client_by_url( iv_url           = p_url
                                                     iv_proxy_host    = p_phost
                                                     iv_proxy_service = p_pserv ).
          "Call the specified URL and retrieve data from the response
          gr_http_client->send( ).
          gr_http_client->receive( ).
          gv_data = gr_http_client->get_response_cdata( ).
          "Its over....
          gr_http_client->close( ).
          "Display result
          REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN gv_data WITH cl_abap_char_utilities=>newline.
          SPLIT gv_data AT cl_abap_char_utilities=>newline INTO TABLE gt_data.
          LOOP AT gt_data INTO gv_data.
            WRITE: / gv_data.
          ENDLOOP.
        CATCH lcx_http_client INTO go_cx.
          MESSAGE go_cx TYPE 'S' DISPLAY LIKE 'E'.
      ENDTRY.
    </pre>

  • How to use URL class instead of Socket

    Hi all. I am developing a small inventory control system for a warehouse.
    I am suing a Java desktop application that connects to a servlet via Internet.
    I have been searching the net how to use JSSE for my application since i am new to secure sockets and JSSE.
    Since I havent implemented security In my current system yet, i am using URLConnection conn = url.openConnection(); to connect to a servlet.
    However, in a good tutorial that I found about JSSE, sockets are used directly for connection, insted of URLCOnnection. They use the code like this: SSLSocketFactory sf = sslContext.getSocketFactory();
    SSLSocket socket = (SSLSocket)sf.createSocket( host, port ); Since, using sockets is overly complex for me, I want to make use of the URLConnection class instead to keep it simple.
    Could anyone please tell me how to make use of the URLConnection class to establish secure http connection.
    by the way, the tutorial is here:
    http://www.panix.com/~mito/articles/articles/jsse/j-jsse-ltr.pdf
    thanks.

    Here you go. The following code snippet allows you post data to http URL. If you have to do the same to https URL , please let me know.
    OutputStream writeOut = null;
    HttpURLConnection appConnection = null;
    URL appUrlOpen = null;
    //data to be posted.
    String data = "This is the test message to post";
    byte[] bytesData = this.data.getBytes();
    appUrlOpen = new URL(""Your Servlet URL");
    appConnection = (HttpURLConnection) appUrlOpen.openConnection();
    appConnection.setDoOutput(true);
    appConnection.setDoInput(true);
    appConnection.setUseCaches(false);
    appConnection.setInstanceFollowRedirects(false);
    appConnection.setRequestMethod("post");
    appConnection.setRequestProperty("Content-Type","application/text");
    appConnection.setRequestProperty("Content-length", String.valueOf(bytesData.length));
    writeOut=appConnection.getOutputStream();
    writeOut.write(bytesData);
    writeOut.flush();
    writeOut.close();
    String inputLine;
    StringBuffer sb = new StringBuffer();
    reader = new BufferedReader(new InputStreamReader(appConnection.getInputStream()));
    char chars[] = new char[1024];
    int len = 0;
    //Write chunks of characters to the StringBuffer
    while ((len = reader.read(chars, 0, chars.length)) >= 0)
    sb.append(chars, 0, len);
    System.out.println("Response " + sb.toString());
    reader.close();
    sb=null;
    chars = null;
    responseBytes = null;
    ******************************************************************************************

Maybe you are looking for

  • Adapter Engine Alert

    Hi, I have set up the alert configuration and I am receiving all the alerts for intergeration server but when I raise any alert for adapter engine.. I am not receiving anything. Is there anything special needs to be done for the same. Please Help ! !

  • Best Laptop for AE7

    I have Premier pro CS3 & AE7. I need to buy a laptop to be more moble. What is working best out there?

  • Most of the .mov and .AVI files doesn't play anymore with QT 7 or 10

    I'm running OS 10.7.5 and most of the .mov files that were generated with Quicktime 7 doesn't play anymore, except in VLC. I used QT7 because it can still crop and edit videos, instead of QT 10 that came with the system. QT7 has a also a very nice fe

  • ITunes not opening after update

    when i click on the iTunes app it do not open

  • Function group SALV

    Hi, I want to do some changes in Funtion group SALV. How can i do the changes. Could anyone suggest me all the steps with T.Code. Thanks in Advance Ravinder