• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Mixing jsp:useBean,c:set,jsp:forward doubt

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose logic.jsp and display.jsp are two pages and Dog.java is a JavaBean with propery as weight
having public no-arg Contructor in the foo package.

Code in logic.jsp
<jsp:useBean id="cloverDog" class="foo.Dog" scope="session">
<jsp:setProperty name="cloverDog" property="weight" value="14"/>
</jsp:useBean>

<c:set target="${colverDog}" property="weight" value="24" scope="session"/>

<jsp:forward>
<jsp aram name="dogParameter" value="${colverDog}"/>
</jsp:forward>

Code in logic.jsp ends here


Code in display.jsp

${param['dogParameter']['weight']}

Code in display.jsp ends here

what will be the output?
I guess it is 24.Please help and comment on the above.Thanks in Advance
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Is it cloverDog or colverDog ?
2. There's no page attribute in your forward.
So please check your syntax

What I can say is that jsp aram is used to pass request parameter strings, not objects. So ${param['dogParameter']} will evaluate to the String returned by Dog#toString. ${param['dogParameter']['weight']} will fail, because the param implicit object is a Map of Strings.
[ December 17, 2007: Message edited by: Christophe Verre ]
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Your logic.jsp page wouldn't compile because <jsp:forward> tag does not use the mandatory "page" attribute.
 
Phani Burra
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Your logic.jsp page wouldn't compile because <jsp:forward> tag does not contain the mandatory "page" attribute.
 
James Mark
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Is it cloverDog or colverDog ?
Sorry Christophe Verre
In <c:set>
it is typo but it has the power to throw an exception.Now only I noticed it.
If there is typo in the property also(if the typo itself is not another property name) has the power of throwing an exception.

2. There's no page attribute in your forward.

Sorry for the fatal mistake......


what would be the result if we

${sessionScope.cloverDog.weight} after the <c:set/> tag in logic.jsp
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what would be the result if we
${sessionScope.cloverDog.weight} after the <c:set/> tag in logic.jsp


Still error. You cannot use the scope attribute with the target attribute in the c:set tag.
Why don't you try it ?
 
James Mark
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
giving me Error in the NetBeans IDE.please help.

Showing some Red colour and application failure occuring.
What should I do?
I tried few examples with Tomcat and Notepad.
Please help thanks in Advance.
 
James Mark
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can I correct this error in the NetBeans IDE?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ask in the IDE forum, or use an editor you know. A simple text editor won't show errors
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic