• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
James Mark
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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 ]
 
Phani Burra
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
how can I correct this error in the NetBeans IDE?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic