0

i am using

sendRedirect("http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=someuser@gmail.com:123456&senderID=TEST SMS&receipientno=0987654321&dcs=0&msgtxt="+ message + "&state=4") 

to call mvaayoo api for sendind sms .But the parameters are displayed in address bar to the client . Is there a way to hide query string? I dont want to purchase SSL certificate.

R9J
  • 6,605
  • 4
  • 19
  • 25
Ruby Agrawal
  • 33
  • 1
  • 8

4 Answers4

0

The problem is not how you redirect, rather the problem is in the provider of the redirect URL you are trying to use:

http://api.mVaayoo.com/mvaayooapi/MessageCompose

No sensitive information should be used as a GET/query param.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
0

Is there a way to hide query string?

Pass additional data as redirect attributes instead of passing it as query parameters.

To carry data across a redirect use RedirectAttributes#addFlashAttribute(key, value).

What Java doc says:

A RedirectAttributes model is empty when the method is called and is never used unless the method returns a redirect view name or a RedirectView.

After the redirect, flash attributes are automatically added to the model of the controller that serves the target URL.

Read more...

Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76
-1

You need to use URLConnection to achieve this:

HTTP GET:

URLConnection connection = new URL(url + "?" + query).openConnection();
connection.setRequestProperty("Accept-Charset", charset);
InputStream response = connection.getInputStream();

Target URL's doGet() method will be called and the parameters will be available by HttpServletRequest#getParameter().

HTTP POST:

URLConnection connection = new URL(url).openConnection();
connection.setDoOutput(true); // Triggers POST.
connection.setRequestProperty("Accept-Charset", charset);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);

try (OutputStream output = connection.getOutputStream()) {
    output.write(query.getBytes(charset));
}

InputStream response = connection.getInputStream();

Target URL's doGet() method will be called and the parameters will be available by HttpServletRequest#getParameter().

sendon1982
  • 9,982
  • 61
  • 44
-1

Take a look

    List<String> pathParam = null;
    if(null!=request.getPathInfo() && !request.getPathInfo().trim().isEmpty()){

        String paths[] = this.getPathInfo().replaceAll("\\/$|^\\/", "").split("/");
        pathParam = new ArrayList<>(Arrays.asList(paths));
     }

    // assume your servlet url  is "/login/*" 

   // called url in browser /login/param1/param2/param3

    String param1 = pathParam.get(0);
    String param2 = pathParam.get(1);
    String param3= pathParam.get(2);
Vicky
  • 603
  • 5
  • 6