Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP -> Servlet and form bean.  RSS feed

 
John Miller
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JSP page the makes use of a form bean, the JSP pages gets submitted to a controller.jsp (MVC Arch.) that initialises the appropriate requesthandler. I'm trying to access the form bean inside the requesthandler, unfortunately it seems to return null.
Below is a snippet of the JSP and the code for the requesthandler.
Any ideas?
Thanks
--SERVLET CODE---------------------------------------
package ui.requesthandlers;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public class TechSupportRequestSubmitted implements ui.RequestHandler {
public String handleRequest(PageContext pageContext, HttpServletRequest request) {
String result = "";
try {
ui.requesthandlers.business.TechSupportBean formBean = (ui.requesthandlers.business.TechSupportBean) request.getAttribute("techFormBean");
if ((formBean.getEmail() != null) || (!formBean.getEmail().equals(""))) {
result = "validationsuccess.htm";
}else {
result = "techsupp.jsp";
}
}catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
}
--SERVLET CODE---------------------------------------
--JSP CODE-------------------------------------------
<%@ page errorPage="systemError" %>
<jsp:useBean id="techFormBean" scope="request" class="ui.requesthandlers.business.TechSupportBean" >
<jsp:setProperty name="techFormBean" property="*" />
</jsp:useBean>
--JSP CODE-------------------------------------------
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!