A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Web Component Certification (SCWCD/OCPJWCD)
JSP - UseBean
Joined: Nov 23, 2005
Apr 25, 2006 11:18:00
Consider the following
<%@ page language="java" import="com.mypackage.MyBean" %>
:useBean id="myBean" class="MyBean"/>
<jsp:setProperty name="myBean" property="myProperty" value="<%=request.getParameter("sentProperty")%>"/>
Public class MyBean
public MyBean(String myProperty)
public void setMyProperty(String myProperty)
this. MyProperty= myProperty;
public String getMyProperty()
Will this give a compilation/translation error? (Beans cannot have constructors with arguments)
Joined: Aug 18, 2005
Apr 25, 2006 12:35:00
why don't you try it out?
it should give an error, not because beans cannot have constructors with arguments, but because beans SHOULD have a no-arg constuctor or what will the container call when it needs to instantiate it?
Joined: Mar 11, 2006
Apr 25, 2006 15:56:00
I agree with Akshay...
A bean class must have a zero-argument (empty) constructor.
You can satisfy this requirement either by explicitly
defining such a constructor or by omitting all constructors, which
results in an empty constructor being created automatically.
I agree. Here's the link:
subject: JSP - UseBean
Mock exam question
jsp:useBean Vs importing class file and using new
Reg useBean standard action
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014