1

How to Hide query string URL in Struts 2.

We are using third party URL , when we hit the URL it open a PDF, we want to hide some parameters in query string URL. In the URL there pass invoice number and Date both parameter we want to hide , when we hit url in any ways.

If we cannot hide the using query string while using URL tag? What is the alternative for the above scenario?

URL: http://dart.corp.xerox.com/WorkplaceXCS/GetDocument?DocumentClass=INV&invno=086664659&invdt=11/01/2016

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • The only way to hide a query from the client is to run it on the server and send the results back to the browser. You could use a POST, but the request is still trivially retrievable from the console. – Dave Newton Mar 23 '18 at 13:07

1 Answers1

0

You can use form tag and hide a parameter with the hidden input field then use URL with the parameter like in following answer.

This is the answer:

You can add a form to trigger a form submit event instead of default link's click event. A form should contain a hidden field to hold a parameter value. Then add javascript code to handle click event.

<s:url action="custACDetails" includeContext="false" var="urlTag"/>
<s:set var="contextPath">${pageContext.request.contextPath}</s:set>
<s:a id="acno" href="%{#contextPath+#urlTag}"><s:property value="acno"/></s:a>
<s:form id="form" action="%{#urlTag}" method="POST">
  <s:hidden name="yourAc" value="%{acno}"/>
</s:form>
<script type="text/javascript">
  $(document).ready(function() {
    $("#acno").click(function(e) {
      e.preventDefault();
      $("#form").submit();
    });
  });
</script>
Roman C
  • 49,761
  • 33
  • 66
  • 176