I’ve webapp1 which has a simple index.jsp
<form method="post" action="TestHarnessClass">
SSN: <input type="text" name="ssn" />
<br />
Username: <input type="text" name="un" />
<br /><br />
<input type="submit" value="Go to user contracts" />
</form>
And a backend servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String ssn = request.getParameter("ssn").trim();
String username = request.getParameter("un").trim();
request.setAttribute("ssn", ssn);
request.setAttribute("un", username);
response.sendRedirect(url);
}
And I can see that the address changed in the browser to the correct url with the un and ssn encoded as query parameters, I inspected the request parameters and it has the ssn and un:
But on the other web app I’ve the following code:
String ssn = request.getParameter("ssn");
String username = request.getParameter("un");
ssn and username are both null. What’s wrong with my code?
I think you should change your Servlet to