Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Question for gurus

 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All!
I am facing some problem (or behaviour?? ) in using jsps.
I am using a MVC architecture for my enterprise application. Here valueBeans acts as Model. Business tier sets these valueBeans and JSP pages use this valueBeans to display the values.
I have requiredment to display java.util.Date in the mm/dd/yyyy format. So i wrote code to format into a desired format and return a string in getDate() method. (Date is attribute of VBean..)
Now this worked fine when i deployed web and ejb jar files in same JVM.
But when i tried to deploy these jar files in different JVMs they just bombed..
As a patch i wrote formatting code in an extra method of VBean called getDisplayDate()..
It worked fine..
Buy my query is that why first approach is failing in case of 2 JVMs where as it is woking fine in single JVM?
VBean is implementing Serializable Interface...
Is this something has to do with the server being used? (I am using Weblogic 6.1 server..)
or Am i trying something against to the JSP specifications?
Any comments on this query is always welcome..
TIA
Rgds
Manohar
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the two methods here and let us take a look at them. It's hard to debug this kind of problem on so little information.
Kyle
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Brown!
Thanks for ur response... As u requested i am giving chunk of codes that i used..

First Approach....
public class XXXVBean implements Serializable
{
...........
private Date some_Date;
...............
public String getSome_Date()
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy");
String dateFormatted="";
if(some_Date==null)
dateFormatted="";
else
dateFormatted= simpleDateFormat.format(some_Date);
return dateFormatted;
}

..................

}
when i used <jsp:getProperty id=some_date property=Some_Date> in JSP
This worked fine in single VM. Buy gives compilation error method getSome_Date or read porperty for Some_Date is not found when tried in 2 VMs.

Second Approach..

I add one more extra method to VBean as follows..
public String getDisplaySome_Date()
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy");
String dateFormatted="";
if(some_Date==null)
dateFormatted="";
else
dateFormatted= simpleDateFormat.format(some_Date);
return dateFormatted;
}
and changes original method as
public Date getSome_Date()
{
return some_date;
}
This works fine in 1 VM and 2 Vms..

I hope this information gives u a clear picture..
Thanks once again..
Rgds
Manohar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic