×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

displaying a bean

displaying a bean

displaying a bean

(OP)
Hello everyone.  I have a small struts problem.

I have the following Action class with an attribute called 'courses'.  I then get forwarded to a .JSP page (called "dispres.jsp") so that I can display the bean.  The problem is that I keep getting the message that it: "Cannot find bean courses in scope session".  Does anyone know how I can fix this?

CODE

public class SearchAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm  form,
           HttpServletRequest request, HttpServletResponse response)
           throws Exception {

        String searchString = ((SearchForm)form).getQuerystring();

        CourseDto courses = new CourseDto(searchString);

        BusinessLayer businessLayer = new BusinessLayerImpl();
        courses = businessLayer.findCourse(searchString);

        System.out.println(courses.getTrainer().getTrainerName());
        System.out.println(courses.getCourseName());

        request.setAttribute("courses", courses);

        return mapping.findForward("dispres");
    }
}


<--**** dispres.jsp after this point ****-->

CODE

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page session="true" import="data.transfer.CourseDto" %>
<%@ taglib uri="struts-html.tld" prefix="html" %>
<%@ taglib uri="struts-bean.tld" prefix="bean" %>
<%@ taglib uri="struts-logic.tld" prefix="logic" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
    <title>Display Search Results</title>
    <meta name="Generator" content="Me, Myself and I">
    <meta name="Author" content="">
    <meta name="Description" content="Search Results Page">

    <html:errors/>

</head>

<body>
<logic:present name="courses" scope="session">

<H3><p>This page displays the search results and allows registration:</p></H3>

<!-- OUTPUT BOX -->
<bean:define id="courses" name="courses" scope="session" type="data.transfer.CourseDto" />

Name:
<bean:write name="courses" property="courseName"/><br>
StartDate:<br />
<bean:write name="courses" property="startDate"/>&nbsp;<br />
End Date:<br />
<bean:write name="courses" property="endDate"/><br />
</logic:present>
<li>After the results are processed, you can select the course and you will be
sent to the registration page to register in the course (if you wish).</li><br />


<br /><br /><br /><br /><br />

<p><A HREF="welcome.jsp">Welcome Page: </A></td></p>

</body>
</html>

RE: displaying a bean

remove the <bean:define...

RE: displaying a bean

Well, it's not strange that this happens... In this line of code in your action

CODE

request.setAttribute("courses", courses);
you're putting the object in the request, not the session.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close