Помимо использования атрибута для передачи информации из сервлета на страницу JSP, можно также передать параметр .Это можно сделать, просто перенаправив URL-адрес, указывающий соответствующую страницу JSP, и добавив обычный механизм передачи параметров через URL.
Пример.Соответствующая часть кода сервлета:
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException
{
response.setContentType( "text/html" );
// processing the request not shown...
//
// here we decide to send the value "bar" in parameter
// "foo" to the JSP page example.jsp:
response.sendRedirect( "example.jsp?foo=bar" );
}
И соответствующая часть страницы JSP example.jsp
:
<%
String fooParameter = request.getParameter( "foo" );
if ( fooParameter == null )
{
%>
<p>No parameter foo given to this page.</p>
<%
}
else
{
%>
<p>The value of parameter foo is <%= fooParameter.toString() %>.</p>
<%
}
%>