httpServletRequest.getParameter returns null

10.2k views Asked by At

I have two servers one (local) and the other (remote calling through vpn).

On both, the same application is deployed.

I stop the vpn to call the local one, so no interference between them.

I am trying to get the param in the servletFilter in doFilter method.

The local is on my pc : weblogic server 11g
The remote is through vpn: weblogic enterprise manager

In the first case httpServletRequest.getParameter returns the expected value of a post request.

In the second gets null.

I am sending to the following url:

http://mydomain/myapp/faces/login-return.jspx

the html form that sends the rquest:

<html>

    <body>
          <form  action="https://mydomain/myapp/faces/login-return.jspx"  method="post">
            <input type="hidden" name="param1" value="value1"  />
            <input type="hidden" name="param2" value="value2"  />
            <input type="submit" name="submit" value="Send to server" />
        </form>
    </body>
</html> 

The code in my servlet filter:

    if (isSessionControlRequiredForThisResource(httpServletRequest, getLoginPage())) {

        if(httpServletRequest.getParameter("param1") != null) {
            httpServletRequest.getSession().setAttribute("param1", httpServletRequest.getParameter("param1"));

        }

any help would be approciated

2

There are 2 answers

3
GingerHead On BEST ANSWER

The problem was that, the server was expecting https calls and not http.

So when I changed my calling protocol to https it started to gather the request parameters like a charm!

1
Juliano Soder On
 @PostMapping("/cookies")
func(HttpServletRequest request) {

        Cookie[] cookies = request.getCookies();
        
         if (cookies != null) {
            //ive goten always null
         }

   }

The error above its the "PostMapping("/cookies")" changed it to "GetMapping("/cookies")" everything starts to work. Its `cause the func cant read the cookies in a post hhtp request without any body present, if yre not seending any data to the back-end than use get method insted.