How the hell does a person share session data between JSP page and a Servle

1. How the hell does one share session data between a servlet and a JSP page without using a bean but rather using a normal string variable.

2. When using session scope to access a bean the application complains about not finding the bean on the specified scope, however when I use an application scope the save the same bean, the application does find it.

Please help!!!!!!!

SERVLET:

HttpSession session = request.getSession(true);

ServletContext servletContext = session.getServletContext();

customerID = result.getString("CustomerID");

userName = result.getString("UserName");

session.setAttribute("UserName",userName);

session.setAttribute("CustomerID",customerID);

System.out.println("Customer UserName = " + session.getAttribute("UserName"));

response.sendRedirect("/economics/subscriptions/default.jsp");

JSP PAGE:

<?xml version="1.0" encoding="UTF-8"?>

<jsp:root xmlns:jsp=http://java.sun.com/JSP/Page mlns:c="http://java.sun.com/jsp/jstl/core" xmlns:sql="http://java.sun.com/jsp/jstl/sql" version="2.0">

<jsp:directive.page isThreadSafe="true" session="true" contentType="text/xml"/><jsp:output omit-xml-declaration="false"/><jsp:scriptlet>response.addHeader("x-xslt-nocache", "true");</jsp:scriptlet><pml>

<page type="web" search="y">

<pageName>Commercial Banking</pageName>

<jsp:directive.include file="/economics/header.inc"/>

<jsp:directive.include file="/login.inc"/>

<jsp:directive.include file="/economics/leftMenu.inc"/>

<!--<jsp:useBean id="UserName" type="java.lang.String" scope="session" />-->

<content>

<searchSum>Commercial - Main Content</searchSum>

Value = <c:out value="${request.session.getAttribute(&quot;UserName&quot;)}"/>

</content>

<jsp:directive.include file="/economics/rightNav.inc"/>

<jsp:directive.include file="/footer.inc"/>

</page></pml></jsp:root>

[2123 byte] By [Harry_O_Za] at [2007-10-3 2:44:01]
# 1
For a start, just "session" instead of "request.session" would work better. But why did you post this here and not in the JSP forum? Doesn't seem to have anything to do with Java programming.
DrClapa at 2007-7-14 20:32:25 > top of Java-index,Java Essentials,Java Programming...