• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bean in jsp

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The code in one jsp is:

<% while(e.hasMoreElements())
{
NewTicket ticketBean = (NewTicket) e.nextElement();
%>
<a href="http://localhost:8084/qatts/ticketdetails.jsp">
<%= ticketBean.getTicketID() %> </a>
....

and the code in another ticketdetails.jsp is:

<jsp:useBean id="NewTicketbean" scope="session" type="ticket.NewTicket" class="ticket.NewTicketImpl" />

<i>Ticket ID</i> <% NewTicketbean.getTicketID(); %>

where NewTicket is an interface which is implemented in NewTicketImpl.java

My question is: which ticketid I click that particular ticketdetails should be displayed in ticketdetails.jsp. For that i have to use that particular bean and I used as shown above. I'm not getting the values and not showing any error also. What is wrong with the above code and how should I get the values?
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To get this:
<% NewTicketbean.getTicketID(); %>
to display in the second jsp, it should read:
<%=NewTicketbean.getTicketID(); %>
[ September 12, 2005: Message edited by: Scheepers de Bruin ]
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand correctly, you have all the ticket details loaded in your first jsp and you create links out of them. Each link carries the ticket id and is linked to ticketdetails.jsp. In ticketdetails.jsp, you attempt to retrieve the bean set by the first rqeuest process for display. Atleast this is what you have set out to achieve ?

However there are several problems with your code (& your design).

1. In your first jsp, you have only created links (using the ticket ids from the bean). You have not set the bean in session scope.

2. Assuming you do (1) above, you would have a set of ticket beans set in session scope. Then when the ticketdetails.jsp is loaded, it will have to know exactly which is the bean (remember the previous jsp set one bean in session scope for each ticket) it has to extract from session scope.

3. What's this enumeration in your first jsp ? Where does it come from ? Does the process which set up this enumeration of ticketbeans in your first jsp also set them in session scope ?

4. One way to work around (2) above is as follows. In the first jsp, when the ticket beans are actually set in scope, set the value of the "id" attribute as the ticketId. Thus when ticketdetails.jsp is requested with a particular ticketid (for this you will have to append the ticketId with each query string), all it has to do is lookup the session scope for a bean whose "id" attribute is the incoming request parameter "ticketId" . There is a catch however. You may not be able to use useBeans because as far as i know, it does not allow runtime expressions for the "id" attribute". You could use jstl el or plain old scriptlets.





Hope this helps.

cheers,
ram.
reply
    Bookmark Topic Watch Topic
  • New Topic