Reputation: 318
I am using same dpPost method for two different form data. I am not able to access request parameters for second form.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if("schema".equals(session.getAttribute("which"))) {
second_html();
//call second page here
}
String btnClicked= request.getParameter("p2"); // This is getting null after submitting second_html()
if("edit".equals(session.getAttribute("which"))){
/* process second page here after Submit on the second page
I am trying to access request.getParameter() but value is null here for the fields in the second page */
second_html();
}
}
first_html() {
// have form and submit button
session.setAttribute("which","schema");
}
second_html() {
// have form and submit button
<input type='text' name='p2' id='p2' size='3' >
session.setAttribute("which","edit");
}
EDIT : My session getters are working fine. But the request.getParameter is not working.
Upvotes: 0
Views: 192
Reputation: 201409
If I understand your question, you should be using ServletRequest.getParameter(String)
,
String v = request.getParameter("which");
if (v.equals("schema")) {
} else if (v.equals("edit")) {
}
Upvotes: 2
Reputation: 11934
You are accessing session variables, not your request parameters.
You can access them using
request.getParameter("which")
Upvotes: 2