tags:

views:

35

answers:

2

Hi I wanna know What is Bean law in JSP part as bean can not have constructor with arguments.When declaring bean object in java no-arg constructor of the bean will run.

+1  A: 

The JavaBeans specification is at (PDF) this location.

The mechanisms for instantiating JavaBeans from JSP don't have any provision for creating beans other than by instantiating using the default constructor. The idea is for these beans to be essentially data transfer objects or containers; any information they contain needs to be put into them using the beans' setters.

You may want to look at JSP Expression language, which allows you to do some "cool" things in your Web page using embedded variables. It's neater and more functional than scriptlets used to be.

Complete specs for JSP and EL are here: http://jcp.org/aboutJava/communityprocess/mrel/jsr245/index.html

Carl Smotricz
+1  A: 

This is not true - a Java Bean is required to have a no-argument constructor, but it's allowed to have constructors with arguments as well.

duffymo