aspose file tools*
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
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: 14688
    
  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: 14688
    
  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