File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
Java Notepad Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
Java Notepad Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic