Web Design and Development Forums

information passed from servlet to JSP

This is a discussion on "information passed from servlet to JSP" within the Java, JSP, Cold Fusion section. This forum, and the thread "information passed from servlet to JSP are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > Java, JSP, Cold Fusion

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Nov 14th, 2007, 14:12   #1 (permalink)
Junior Member
 
Join Date: Oct 2007
Location: Holland
Posts: 49
information passed from servlet to JSP

hello,
sorry for cross-posting, but I first put my thread in the JavaScript forum...

so, here is my problem:

In my JSP pages I'd like to use a certain info passed by the controller servlet.

For instance, in my servlet I have the following:
Code: Select all
Animal myAnimal = new Animal();
// Set attributes
request.setAttribute("myAnimal", myAnimal);
getServletContext().getRequestDispatcher("/myJSP.jsp").forward(request, response);
Now in the jstl tags of myJSP.jsp I can use the following:
Code: Select all
<c:forEach items='${myAnimal.body.legs}' var="leg">
   ......
</c:forEach>
BUT I cannot use the following:
Code: Select all
<% for(int i=0; i<myAnimal.getBody().getLegs().length; i++) { %>
   ......
<% } %>
... it complains that myAnimal cannot be resolved

I also tried:
Code: Select all
<%@ page import="com.mycompany.Animal" %> 
<%! Animal jspAnimal = (Animal)request.getAttribute("myAnimal"); %>
...but then I get "request cannot be resolved" for the second line...


Could you please explain why I cannot use "myAnimal" in the plain JSP tags???


Thans a lot ! ! !
pesho318i is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with my Servlet - retrieving images from database Love2Java Java, JSP, Cold Fusion 1 Dec 19th, 2007 13:20
Formatting Passed Value Within ASP Page In Textarea? Monie ASP Forum 15 Nov 27th, 2007 23:57
[SOLVED] AJAX call to a servlet pesho318i JavaScript Forum 9 Oct 28th, 2007 12:40
search results with servlet or JSP twix_ Java, JSP, Cold Fusion 1 Nov 2nd, 2006 21:25



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 23:05.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59