Thursday, June 16, 2016

How to get the referred/called url

I want to find the URL from which my page is called or from which my page is redirected. The example is given below.


Example
@InjectObject(value = "service:tapestry.globals.RequestGlobals")
public abstract RequestGlobals getRequestGlobals();

HttpServletRequest httpServletRequest = requestGlobals.getRequest();
String referrer =httpServletRequest.getHeader("referer");

Test

test

Call SOAP Webservice from javascript

Example


<html>
   <head>
      <title>SOAP Sample</title>
      <script type="text/javascript">
         function soapCall() {
             var xmlhttp = new XMLHttpRequest();
             xmlhttp.open('POST', 'soapurl', true);
             // build SOAP request
             var sr =
                 '<?xml version="1.0" encoding="utf-8"?>' +
                 '<soapenv:Envelope ' +
                     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                     'xmlns:api="url" ' +
                     'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                     'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
                     '<soapenv:Body>' +
                         '<api:parm1>' +
                             '<api:param>2014_DAY_339_2</api:param>' +
                         '</api:parm1>' +
                     '</soapenv:Body>' +
                 '</soapenv:Envelope>';
        
             xmlhttp.onreadystatechange = function () {
                 if (xmlhttp.readyState == 4) {
                     if (xmlhttp.status == 200) {
         alert('--'+xmlhttp.response);
                     }
                 }
             }
             // Send the POST request
             xmlhttp.setRequestHeader('Content-Type', 'text/xml');
             xmlhttp.send(sr);
         }
        
      </script>
   </head>
   <body>
      <script type="text/javascript">
         soapCall();
      </script>
   </body>
   <html>
</html>