-1

I am sending html table containing data from servlet to my jsp page. My servlet code is following:

String html = "<table><thead><th>Serial</th><th>MAC</th></thead>"
              + "<tbody>
              + "<tr>1000234<td></td><td>9845HM98</td></tr>"
              + "<tbody>"
              + "</table>";

request.setAttribute("responselDetails", html);

ServletContext context= getServletContext();
RequestDispatcher rd= context.getRequestDispatcher("/jsp/Details.jsp");
rd.forward(request, response);

jsp:

<% if (request.getParameter("responsePeripheralDetails") != null) { %>
<%= request.getParameter("responsePeripheralDetails") %>
<% } %>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

2

Seems like you mixed request.setParameter() and request.setAttribute()

You are setting request.setAttribute() in servlet and trying to access it via request.getParameter() in jsp which always give exception of nullPointer.

quick fix: correct getParameter() to getAttribute() in jsp and you are done :-)

<% if (request.getAttribute("responsePeripheralDetails") != null) { %>
<%= request.getAttribute("responsePeripheralDetails") %>
<% } %>
mumair
  • 2,768
  • 30
  • 39