我對兩種不同的表單數據使用相同的dpPost方法。我無法訪問第二種形式的請求參數。無法訪問java servlets中的請求參數
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");
}
編輯:我的會話getters工作正常。但是request.getParameter不起作用。
'我不能夠訪問請求參數爲第二form'。很不清楚。你能詳細說明嗎? –