java - How to access a request attribute set by a servlet in JSP? -


i'm trying retrieve attribute values set servlet in jsp page, i've luck parameters ${param}. i'm not sure can different. maybe simple, couldn't manage yet.

public void execute(httpservletrequest request, httpservletresponse response) {      //there's no "setparameter" method "request" object     request.setattribute("attrib", "attribvalue");      requestdispatcher rd = request.getrequestdispatcher("/test.jsp");     rd.forward(request,response); } 

in jsp have been trying retrieve "attribvalue", without success:

<body>     <!-- there tag instead of "param"??? -->     <p>test attribute value: ${param.attrib} </body> 

if pass parameter through process (invoking page, servlets , destination page), works quite good.

it's available in default el scope already, just

${attrib} 

should do.

if explicitly specify scope (el namely search page, request, session , application scopes in sequence first non-null attribute value matching attribute name), need refer scope map instead, ${requestscope} request scope

${requestscope.attrib} 

this useful if have possibly attribute same name in page scope otherwise precedence (but such case indicate poor design after all).

see also:


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -