File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes displaying time of last visit of user on the page using cookie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "displaying time of last visit of user on the page using cookie" Watch "displaying time of last visit of user on the page using cookie" New topic
Author

displaying time of last visit of user on the page using cookie

Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

Hi
I made a JSP code to display time of last visit of user on the page using cookie. My code is-

but instead of getting time, i am getting some alphaneumeric string. Someone please check my code and help me sorting out the problem.
thanks in advance..


Astha - OCPJP 6 (90%)
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6



Swastik
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

Swastik Dey wrote:

Thanks for the reply Swastik, but what will be the effect of this? Here both conditions all!=null and all.length>0 are same. I tried this but the result is same as previous.
sagar kumar nerella
Greenhorn

Joined: Jul 09, 2011
Posts: 18

just simple modification you need to do
i.e while getting the value through getValue() cast it to the string object or date object and then call toString() on that.


sagar kumar nerella,
java certified professional
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61419
    
  67

Java code in a JSP? In 2012?

Astha Sharma wrote: i am getting some alphaneumeric string


Don't you think that it might be helpful to show exactly what "some alphanumeric string" is?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

sagar kumar nerella wrote:just simple modification you need to do
i.e while getting the value through getValue() cast it to the string object or date object and then call toString() on that.


but the value returned by getValue() is already of String type and value of the cookie is date so it should automatically display date.
Bear Bibeault wrote:Java code in a JSP? In 2012? :shock:

Astha Sharma wrote: i am getting some alphaneumeric string


Don't you think that it might be helpful to show exactly what "some alphanumeric string" is?

I have just started learning JSP so shoudn't I start from basics? This is the alphaneumeric string which im getting-
62165E019EC28823D68D7C630294D220
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61419
    
  67

Astha Sharma wrote:I have just started learning JSP so shoudn't I start from basics?

Scriptlets are not "the basics"? They were replaced by the JSTL and EL 10 years ago in 2002. They should never ever be used. Ever.

This is the alphaneumeric string which im getting- 62165E019EC28823D68D7C630294D220

What does the browser say that the value of the cookie is?

(That looks suspiciously like a long value -- hint.)
sagar kumar nerella
Greenhorn

Joined: Jul 09, 2011
Posts: 18

Astha Sharma wrote:
sagar kumar nerella wrote:just simple modification you need to do
i.e while getting the value through getValue() cast it to the string object or date object and then call toString() on that.


but the value returned by getValue() is already of String type and value of the cookie is date so it should automatically display date.
Bear Bibeault wrote:Java code in a JSP? In 2012? :shock:

Astha Sharma wrote: i am getting some alphaneumeric string


Don't you think that it might be helpful to show exactly what "some alphanumeric string" is?

I have just started learning JSP so shoudn't I start from basics? This is the alphaneumeric string which im getting-
62165E019EC28823D68D7C630294D220


then just use that string value to create a date object and call the toString() on it .
because the string value representing the long value.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: displaying time of last visit of user on the page using cookie