3

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

GingerHead
  • 8,130
  • 15
  • 59
  • 93
  • Did you add some log messages to ensure it cannot be a side effect of `isSessionControlRequiredForThisResource` returning false ? – Serge Ballesta May 20 '14 at 21:40
  • 1
    Maybe you make a cross domain request in the second case? (it's not clear from the code) I'm not sure but that might be the reason why the parameters are null (see [link](http://stackoverflow.com/questions/11423682/cross-domain-form-posting)) – Vadim May 20 '14 at 22:53
  • @SergeBallesta how can it be a side effect of isSessionControlRequiredForThisResource ? – GingerHead May 21 '14 at 04:29
  • @Den what do you mean by make a cross domain request? – GingerHead May 21 '14 at 04:29
  • @GingerHead If `isSessioncontrolrequiredforthisresource` retiens fasse your code is never called and your session paramétrer romains null. – Serge Ballesta May 21 '14 at 11:56

2 Answers2

1

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!

GingerHead
  • 8,130
  • 15
  • 59
  • 93
  • 1
    In other words when you said you were 'sending to the following URL: https://...', and you had 'action="https://..."', you weren't, and you didn't. It's hard to see how that alone would cause this problem. It sounds more like you were redirecting incorrectly. – user207421 May 24 '14 at 12:35
  • @EJP Yes exactly, that was a typo, I was sending http. The local server was ok with it, but the enterprise manager was expecting https (it was configured like that). It acted upon the http calls normally though by responding back with https, weird no? – GingerHead May 24 '14 at 12:40
  • @EJP But this is a normal behavior of FacesServlet? – GingerHead May 24 '14 at 12:43
0
 @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.

  • Good morning, the fact is that, as I said in the above answer, the issue was with the protocol and not with the method type. Thanks anyway, it may help others who have a similar issue like yours. – GingerHead Oct 12 '22 at 15:06