0

we have an application made with JSF 1.2. We use JBoss 4.2 and Apache.

The issue we are having appears randomly in the production enviroment.

We have in a JSP page an static link, similar to:

<a href="https://myhost/mypage.jsp?param=MYPARAM">link</a>

MYPARAM is encoded with BASE64.

In mypage.jsp file we do the next:

<body>
<% String param = request.getParameter("param");
   String decoded = new BASE64Decoder().decodeBuffer(param));%>
...

Sometimes, the string param it's NULL so then it launches a NullPointerException.

As you can see it's something pretty simple.

Some ideas about what's going on here? I've been googling for days and I don't find a clue about what's going on...

We have the same issue in another part of our code where we do a:

FacesContext facescontext = FacesContext.getCurrentInstance();
facescontext.getExternalContext().redirect("/myservlet?param=TYPE");

The var TYPE it's missing sometimes, producing another NullPointerException in other parts of our code, when it never should be NULL.

Thanks.

maqjav
  • 2,310
  • 3
  • 23
  • 35
  • Instead of passing as ?param=MYPARAM, try this : &param=MYPARAM. That means instead of ? , use &. That might work. Do tell me whether it works . – The Dark Knight Feb 05 '13 at 11:31
  • 1
    @TheDarkKnight: complete nonsense. The `?` is to separate query string from URI and the `&` is to separate the parameters in query string itself (and the `=` is to separate the parameter name and value). Go back to the books to learn basic HTTP. – BalusC Feb 05 '13 at 11:35
  • @BalusC : Before you say something does not make sense , take time and patience to know that it does not exactly make sense. What i have said is learnt from a practical POV. Sometimes the ? does not work in a query string as the posted value does not take it as a delimeter. And dont presume to tell me about basic http without verifying whether what i have said does really amount to something or not . – The Dark Knight Feb 05 '13 at 11:44
  • 1
    Wrap encoding and decoding in your own functions, and log errors with their values. Check `+` and the padding at the end with `=`. Every char is 6 bits, so the length best should be a 4-fold (3 bytes). Also some encoding classes adds line breaks. – Joop Eggen Feb 05 '13 at 11:44
  • @Joop: OP mentioned that the value is static (as in, hardcoded). So an intermittent NPE is unexpected. – BalusC Feb 05 '13 at 11:45
  • @maqjav Not related to the problem.. Try avoiding Scriplets in JSP – Vikas V Feb 05 '13 at 11:51

1 Answers1

0

inside jsp page

<a href="http://myhost/mypage.jsp?param=MYPARAM">link</a>

inside mypage.jsp

String param = request.getParameter("param");

work is fine