Hello everyone,

I need to pass some parameters from my servlet to my JSP. I am able to access 2 of my parameters from the request object, but one of them is returning null value.

Here's my servlet snipet:

            request.setAttribute("selectedA", aBook);
            request.setAttribute("selectedB", bBook);
            request.setAttribute("book_ref", book_ref);
            logger.info("book_ref = " + book_ref);  // <-- The value for book_ref is correct in my servlet.
            RequestDispatcher rd = request.getRequestDispatcher("/jsp/book.jsp");
            rd.forward(request, response);

From my JSP, here's the snipet: The first two parameters are coming back alright. The last one comes back null. In my servlet, I do a printout, and the value of book_ref is correct. Anything I am missing????

            A-Book =  ${param.selectedA} <br>
            B-Book = ${param.selectedB} <br>
            Book-Ref = ${param.book_ref}

Recommended Answers

All 4 Replies

I would suggest to debug, because two parameters before this one are fine. It does look like you are actually pushing NULL instead of some value for book_ref

Thank you Peter.

Actually, the logger spits out the value of book_ref alright in my servlet. But, when I try to access it from my JSP, it returns null.

The value of book_ref is coming from mySQL table, whereas the balue of aBook and bBook are coming from my other JSP form passed as parameter to my servlet, and i simply forward them along with my book_ref to my respond JSP [book.jsp].

I tried to debug from my eclipse, but how can i perform a step debug on my JSP? Thanks.

What do you mean by step debugging?
If you are referring to debug capabilities of eclipse where you can debug servlets during runtime, such runtime debugging is not available in eclipse for JSP. JSP debugging during runtime are available in "intellij idea" tool.

Thanks Peter. Appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.