Code Hungry
Code Hungry

Reputation: 4000

How to assign bean value to html:text in jsp

<bean:write scope="session" name="USERSESSION" property="userId" />

<html:text tabindex="1"  name="RequestForm" property="currentuser" value='<bean:write scope="session" name="USERSESSION" property="userId" />' readonly="true"/>

What are the other ways to assign Bean value to Html:text default value

Upvotes: 2

Views: 3320

Answers (3)

kaushikjain
kaushikjain

Reputation: 291

You can try something like

<jsp:useBean id="USERSESSION" scope="session" type="<DATA_TYPE>">
<html:text tabindex="1"  name="RequestForm" property="currentuser" value='<%=USERSESSION.getUserid()%>' readonly="true"/>

Upvotes: 2

Srinu Chinka
Srinu Chinka

Reputation: 1491

You can not combine <bean> tags with <html> tags.

Use <bean:define> to define a variable with an id and next use id with JSP EL to set the value to <html:text> tag.

Try the following:

<bean:define id="sessUserId" scope="session" name="USERSESSION" property="userId" />

<html:text tabindex="1"  name="RequestForm" property="currentuser" value='${sessUserId}' readonly="true"/>

Upvotes: 2

Alexandre Fillatre
Alexandre Fillatre

Reputation: 132

You can't have a taglib inside an attribute of another taglib. What you need to do, is set the variable in the page, then use it later.

See http://www.tutorialspoint.com/jsp/jstl_core_set_tag.htm for example.

Upvotes: 0

Related Questions