aspose file tools*
The moose likes Servlets and the fly likes need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "need help" Watch "need help" New topic
Author

need help

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jun 03, 2000
Posts: 5040

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

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jan 31, 2000
Posts: 1467
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

Joined: Sep 14, 2000
Posts: 4

Thank you I'll check it out
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Sep 14, 2000
Posts: 4
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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Dec 14, 1998
Posts: 20529
    ∞

PROPER NAMES ARE NOW REQUIRED!
See http://www.javaranch.com/ubb/Forum10/HTML/000180.html for details.

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Dec 14, 1998
Posts: 20529
    ∞

Take a look at the link and it will explain everything.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: need help