• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:set problem

 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a bean:


Servlet:
=========


JSP:
----
<c:set target="${dogAttr}" property="dogName" value="Jimmy"/>
Dog Name :: <jsp:getProperty name="dogAttr" property="dogName"/><br>

Output:
========
Dog Name :: Jimmy

Whether I have used the target is correct..? It should be the attribute name or actual object.. com.example.model.Dog

The below one is not executing and giving error:

<c:set target="${com.example.model.Dog}" property="dogName" value="Jimmy"/>
Dog Name :: <jsp:getProperty name="dogAttr" property="dogName"/><br>
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please post the stack trace ???
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also what my doubt is whether for target only object should use or attribute name also can use, it it maps to an object.
Example:
Dog d = new Dog();
request.setAttribute("dogAttr",d);

<c:set target="${d}" ...

or

<c:set target="${dogAttr}" ...

Which one to use? If we can use both the option, I am getting the error for the first option..and the stackTrace given below..




[ January 21, 2007: Message edited by: Micheal John ]
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as per my knowledge,
${dogAttr} should work very well..
from the stack trace..i advice you to do this

goto

tomcat_dir/work/Catalina/localhost/your_web_dir/org/apache/jsp
and delete the .java and .class files there
restart the server..and run your application again..

hth
let me know the progress !
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Example:
Dog d = new Dog();
request.setAttribute("dogAttr",d);

<c:set target="${d}" ...

or

<c:set target="${dogAttr}" ...

Which one to use? If we can use both the option, I am getting the error for the first option..and the stackTrace given below..




To Niranjan Deshpande:

I am afarid that you didn't understand my question properly..
${dogAttr} works fine me also...
I have mentiond ${d} is not working properly...
for target we have to mention only the attribute name, which *SHOULD* resolve to an object..? This is correct or not..or someother thing also we can use it in the target? This my qustion..
[ January 21, 2007: Message edited by: Micheal John ]
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have mentiond ${d} is not working properly...

this doesnt work, because, though its a real thing,i mean a Dog object,
its no where in any of the four scopes, so it doesnt work...! the "d" is known as a "dogAttr" in your request scope..! so ${dogAttr} should be used and not ${d} , it doesnt work, even if its a REAL DOG.

got it ??
if you get that kinda stack trace some time in your j2ee life,
be sure to do what i told above..
i am telling you from my on job experience !

thanks
hopw i solved your query
[ January 21, 2007: Message edited by: Niranjan Deshpande ]
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help!!
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did i solve your query ???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic