• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic