wood burning stoves 2.0*
The moose likes JSP and the fly likes setting attribute using EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "setting attribute using EL" Watch "setting attribute using EL" New topic
Author

setting attribute using EL

Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Hello,

can this be done using EL:

<% request.setAttribute("username");%>


Ken Sampson
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

can this be done using EL:

No. EL is used to read values, not to set values. Remember that a JSP is usually used as a view, so all you should do is read data.


[My Blog]
All roads lead to JavaRanch
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

i hope you mean
<% request.setAttribute("username", "user123"); %>

You can do this using JSTL EL,


or
if userName is a request parameter.


but as Christophe said, try to avoid setting variables in request, session, application scopes inside JSP (instead use controller). If you want to create temporary variables inside jsp, create those in "page" scope (in c:set, simply dont mention "scope" attribute).


- Marimuthu Madasamy
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You can do this using JSTL EL

c:set is a JSTL tag, not something from the Expression Language ;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting attribute using EL
 
Similar Threads
including webpage in jsp
concatenate Text Fields in JSP
problems with EL in jsp and java bean
Need an attribute to be available in different places (SOLVED)
java 1.5 list iteration using jstl tag