Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam a beginner in java programming. help....

How to get URL of the previous visited page in the currentpage?
how to find the difference between two Dates?

My Email id:chaluvadiv@usa.net
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am not sure what you are asking or the context of
you discussion....Could you pl elaborate on this....
what confuses me most is that you say you are a beginner
Regds.
- satya
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
clarification Q no1: After submission of a webpage,it should lead the user to the previous visited page. I used HttpServletRequest.getRequestURI(), but after submission its leading to the same page and I want the previous visited page.
pl drop the possible ways to handle it.
clarification Qno2: I have two java.util.date objects.How to find the difference between those two dates in the form of a String or any format(preferably like "1 year", "2 1/2 years")
Please give the block of code to solve that.
I expect that you understand my questions.
venkat
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chaluvadiv,
Here is a solution dor your question 1.
The logic I used is, grab the current URL from HttpUtils.getRequestURL(req) method and put it in the user's session with a tagName like 'Prev_Visit_Url' (which I used in the following code). I assume you use servlets for this. So in the servlet at any time we can check for the CURRENT_URL and PREV_URL. I tested this code with one of my web application for you. It works fine.
Instead of HttpUtils.getRequestURL(req) you can also use your method .getRequestURL() also.
regds
maha anna


[This message has been edited by maha anna (edited September 16, 2000).]
 
venkateswarlu chaluvadi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you I'll check it out
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Q2). Can't you just invoke getTime() on the two date objects and convert the difference(in milli seconds) into appropriate scale?
fl
 
venkateswarlu chaluvadi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want difference between two date objects in days. I expect professionals to drop a bit of code for the above mentioned problem.
Thanx,
venkat
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're being lazy - what more do you need?
You get the time diffenece in milliseconds - just figure out how many millisecs there are in a day(24*60*60*1000), and divide the diffenece by this number!
fn
 
paul wheaton
Trailboss
Pie
Posts: 21469
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PROPER NAMES ARE NOW REQUIRED!
See http://www.javaranch.com/ubb/Forum10/HTML/000180.html for details.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "Proper" do you mean "real"? In that case how are you going to find out whether one's using "Proper" name or not?
fn
 
paul wheaton
Trailboss
Pie
Posts: 21469
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the link and it will explain everything.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic