Tutorial Home
Hibernate
-
Advantage of Hibernate over JDBC
- Hibernate Setup with an web Application
- First Hibernate Application
- Hibernate mapping with Database TABLE
- Hibernate Data Type-Java Data Type - SQL Data Type mapping
- One to Many Relation in Hibernate
- One to Many Relation in Hibernate bi-directional
- Many to Many Relation in Hibernate
- HQL: The Hibernate Query Language
- Criteria Queries
- Criteria Queries : Equal (eq), Not Equal(ne), Less than (le), greater than (gt),greater than or equal(ge) and Ordering the results
- Criteria Queries: And OR conditions
- Hibernate generator to generate id (primary key)
- prevent concurrent update in Hibernate,slate object updatation in Hibernate,version checking in Hibernate
Struts
- Model View Controller (MVC)
- Model View Controller (MVC)
- Struts Flow-How Struts Works?
- Struts Tutorial - Struts Setup- First Struts Action class setup
- Message Resources
- Validation Framework
- Validation Framework-client side
- ForwardAction
- IncludeAction
- DispatchAction
- LookupDispatchAction
- DynaActionForm
- DynaActionForm
- Struts Tutorial - Mutli-click prevention using struts tokens-Prevent Duplicate Submission
- Logic Iterate Map and List
JSP
- JSP Tutorial
- Introduction to JSP
- JSP Comments
- JSP Syntax
- JSP Scripting Elements :Scriptlet, expression, declaration
- JSP Directives
- implicit objects in JSP
- JSP Actions
- Introduction to JSP
- jsp:useBean
- The jsp:setProperty Action
- The jsp:getProperty Action
- Introduction to JSP
Spring
- Spring Tutorial
- Introduction to Spring
- Benefits of Using Spring Framework
- Inversion of Control in Spring
- Introduction to BeanFactory
- Dependency Injection in Spring
- Collections Setter Injection
- Bean Scopes in Spring
- Spring IOC Setup Step by Step
- Bean Lifecycle in Spring
- ApplicationContext
- MessageSources in Spring
- Web Spring MVC framework
- Developing Your First Spring Web Application
- Developing Your Second Spring Web Application with Spring Form
- Developing Your First Spring Web Application with Spring Validation Framework with Code Example
- Spring integration with Hibernate
|
JSP Tutorial Step by Step
The jsp:setProperty Action
The jsp:setProperty Action
This element set the value of a bean property. Like emp.setName() in Java.
Synatax is :
<jsp:useBean id="myName" ... />
...
<jsp:setProperty name="myName"
property="someProperty" ... />
Here is a very simple example
test.jsp
<HTML>
<HEAD>
<TITLE> JavaBeans in JSP</TITLE>
</HEAD>
<BODY>
<jsp:useBean id="test" class="com.EmpBean" />
<jsp:setProperty name="test"
property="name"
value="Das" />
Name is :
<jsp:getProperty name="test" property="name" />
</BODY>
</HTML>
Output is :
Name is : Das
<jsp:setProperty name="test"
property="name"
value="Das" />
is equivalent to
test.setName("Das");
EmpBean.java
Here's the source code for the bean used in the test.jsp page.
package com;
public class EmpBean {
private String name = "";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
The below code
<jsp:useBean id="test" class="com.EmpBean" />
is equivalent to
com.EmpBean test = new com.EmpBean();
and
<jsp:setProperty name="test"
property="name"
value="Das" />
is equivalent to
test.setName("Das");
and
<jsp:getProperty name="test" property="name" />
is equivalent to
out.println(test.getName());
There are four possible attributes of jsp:setProperty:
| Attribute
| Usage
|
name
| This required attribute designates the bean whose property
will be set. The jsp:useBean element must appear before
the jsp:setProperty element.
|
property
| This required attribute indicates the property you want to set. However, there is
one special case: a value of "*" means that all request parameters
whose names match bean property names will be passed to the
appropriate setter methods.
|
value
| This optional attribute specifies the value for the property.
String values are automatically converted to numbers, boolean,
Boolean, byte, Byte, char,
and Character via the standard valueOf method
in the target or wrapper class. For example, a value
of "true" for a boolean or Boolean
property will be converted via Boolean.valueOf, and a value
of "42" for an int or Integer property will be
converted via Integer.valueOf. You can't use both value
and param, but it is permissible to use neither. See the discussion of
param below.
|
param
| This optional attribute designates the request parameter from which
the property should be derived. If the current request has no such
parameter, nothing is done: the system does not pass null to
the setter method of the property. Thus, you can let the bean itself supply
default values, overriding them only when the request parameters say to
do so. For example, the following snippet says "set the empName
property to whatever the value of the name request parameter is, if
there is such a request parameter. Otherwise don't do anything."
<jsp:setProperty name="emp"
property="empName"
param="name" />
If you omit both value and param, it is the same as if you supplied
a param name that matches the property name.
You can take this idea of automatically using the request property
whose name matches the property one step further by supplying a property name of
"*" and omitting both value and param.
In this case, the server iterates through available properties and
request parameters, matching up ones with identical names.
|
|
|