This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply 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: 206

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..
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1195



Swastik
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 206

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: 56192
    
  13

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?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 206

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: 56192
    
  13

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: displaying time of last visit of user on the page using cookie
 
Similar Threads
How to set date in mysql using prepared statement?
How to disable cookies
cookie and jsp
cookie setDomain problem.
SESSION TRACKING.