[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

JSP; Servlets;  html: How do I retreave a value from a session object into a JSP?

Posted on 2004-08-20
5
Medium Priority
?
229 Views
Last Modified: 2010-04-01
One of my servlets, Address.java binds a value to a session object:
       HttpSession session = request.getSession(true);
      session.setAttribute("location", lcn);

Then I have a JSP to display a table, but the value is not retrieved from the session object.

FOR EXAMPLE, the following does not work:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page session="true"%>

<html>
<body>
<center>
<table cellpadding=4 cellspacing=2 border=0>
 
<th bgcolor="#CCCCFF" colspan=3>
<font size=4>THE LOCATION</font>
<br>
<br>
</th>

<tr bgcolor="#c8d8f8">
<td valign=top>
<b>Location</b>
<br><br>
<% String location = (String) session.getAttribute("location"); %>

What am I missing in the above four lines to make them work?
I get no error message. The table displays but without the value of location. I'd appreciate your instruction.
0
Comment
Question by:Rrugemalira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 14

Assisted Solution

by:sudhakar_koundinya
sudhakar_koundinya earned 2000 total points
ID: 11855514
is servlet called before JSP execution??
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 2000 total points
ID: 11855534
HttpSession session = request.getSession(true);
     session.setAttribute("location", lcn);
System.err.println(lcn);  //test this whether u r getting right value here itself
0
 

Author Comment

by:Rrugemalira
ID: 11856201
I've discovered I had to add one line <%= location %> to have the following that works:

                     <tr bgcolor="#c8d8f8">
                     <td valign=top>
                     <b>Location</b>
                     <br><br>
                     <% String location = (String) session.getAttribute("location"); %>
                     <%= location %>
Thanks
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11856231
ok

u can close the question now

ask community support people for help
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11856265
I should say great theanks to you.

0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question