my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes c:set problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "c:set problem" Watch "c:set problem" New topic
Author

c:set problem

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
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>


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
can you please post the stack trace ???


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
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

Joined: Oct 16, 2005
Posts: 1277
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

Joined: Nov 01, 2006
Posts: 344

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

Joined: Oct 16, 2005
Posts: 1277
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

Joined: Nov 01, 2006
Posts: 344
Thanks for your help!!
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
did i solve your query ???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c:set problem
 
Similar Threads
unable to set the value of Internal attribute using <c:set>
EL Execution Problem
How to retrive values from the database
difference between c:set with-body and no-body versions
Simple EL code is not working