473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

JSP/Servlets and URL's

When someone accesses my website with a URL like
http://ww**********@myreal.website.com, I want to be able to access
the full URL. I can't seem to find a way to do this... is it
possible?

For reference: request.getRequestURL() for the above URL will return
"http://myreal.website.com" thus losing the "www.ebay.com" part. I
need a way of getting the exact requested URL.
Jul 17 '05 #1
7 6629
On 8 Nov 2003 07:31:22 -0800, da*****@googlenews.test.xhome.us
(DaiIchi) wrote:
When someone accesses my website with a URL like
http://ww**********@myreal.website.com, I want to be able to access
the full URL. I can't seem to find a way to do this... is it
possible?

For reference: request.getRequestURL() for the above URL will return
"http://myreal.website.com" thus losing the "www.ebay.com" part. I
need a way of getting the exact requested URL.


Never mind. I found the answer to my problem: it cannot be done.
It's not a fault of the JSP (or Java) design. Although the above URL
is, by BNF definition, a valid URL, the browser only sends a "GET /"
with a "Host: myreal.website.com" -- which means that the extraneous
text "www.ebay.com" is lost.

Oh well, back to the drawing board.

Jul 17 '05 #2
On Sat, 08 Nov 2003 07:31:22 -0800, DaiIchi wrote:
When someone accesses my website with a URL like
http://ww**********@myreal.website.com, I want to be able to access
the full URL. I can't seem to find a way to do this... is it
possible?

For reference: request.getRequestURL() for the above URL will return
"http://myreal.website.com" thus losing the "www.ebay.com" part. I
need a way of getting the exact requested URL.


the part before the @ is the username part. it can contain for ex a
username and password to access an ftp site.

You can get the user information with the

getUserInfo()

method.

Jul 17 '05 #3

What class/package is getUserInfo() in? I viewed the page request
over port 80 and didn't see the browser transmitting the
username/password pair.... so I assume that it is inaccesible in an
HTTP session. I hope I was wrong.
On Sun, 09 Nov 2003 18:18:20 +0100, "TeCh" <Te**@spelletjesgarnaal.be>
wrote:
On Sat, 08 Nov 2003 07:31:22 -0800, DaiIchi wrote:
When someone accesses my website with a URL like
http://ww**********@myreal.website.com, I want to be able to access
the full URL. I can't seem to find a way to do this... is it
possible?

For reference: request.getRequestURL() for the above URL will return
"http://myreal.website.com" thus losing the "www.ebay.com" part. I
need a way of getting the exact requested URL.


the part before the @ is the username part. it can contain for ex a
username and password to access an ftp site.

You can get the user information with the

getUserInfo()

method.


Jul 17 '05 #4
The getUserInfo() method is a method of the URL class, but apparently
there's no way to get a URL object out of a servlet request :-(.

Google told me that

a method from the HttpUtils class should give me the full url but it
doesn't work for me.

On Mon, 10 Nov 2003 00:30:54 -0800, DaiIchi wrote:
What class/package is getUserInfo() in? I viewed the page request over
port 80 and didn't see the browser transmitting the username/password
pair.... so I assume that it is inaccesible in an HTTP session. I hope I
was wrong.


Jul 17 '05 #5
"TeCh" <Te**@spelletjesgarnaal.be> wrote in message news:<pa****************************@spelletjesgar naal.be>...
The getUserInfo() method is a method of the URL class, but apparently
there's no way to get a URL object out of a servlet request :-(.

Google told me that

a method from the HttpUtils class should give me the full url but it
doesn't work for me.

On Mon, 10 Nov 2003 00:30:54 -0800, DaiIchi wrote:
What class/package is getUserInfo() in? I viewed the page request over
port 80 and didn't see the browser transmitting the username/password
pair.... so I assume that it is inaccesible in an HTTP session. I hope I
was wrong.


Ah, that explains it. I now know what you were proposing. But even
if request.getRequestURL() (for example) returned a URL object, the
getUserInfo() would have been meaningless. Try this:

import java.io.*;
import java.net.*;

public class test {

public static void main(String args[]) throws Exception {

ServerSocket ssocket = new ServerSocket(80);
Socket s = ssocket.accept();

InputStream is = s.getInputStream();
int ch = 0;
while ( (ch = is.read()) != -1) {
System.out.print((char) ch);
}
}
}
Run it... and then open a browser an type the URL:

http://somepretendusername@localhost

You should see:

GET / HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4)
Gecko/20030624
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plai
n;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

Notice how "somepretendusername" is *nowhere* in the browser-to-client
dialogue? So this portion of the username (and password) portion of a
URL is not passed to a web server in an HTTP exchange. Hence, Java
would have no way to even form a URL object with a working
getUserInfo() from the data above.

This is not a flaw of Java, as I said, it appears to be an issue with
the HTTP specification: even though username/password is a valid
formation of a URL, it isn't being passed by any of the browsers I
have (Mozilla or Internet Explorer). It would have been really useful
to me if it worked, though.
Jul 17 '05 #6
DaiIchi wrote:
"TeCh" <Te**@spelletjesgarnaal.be> wrote in message
news:<pa****************************@spelletjesgar naal.be>...
The getUserInfo() method is a method of the URL class, but apparently
there's no way to get a URL object out of a servlet request :-(.

Google told me that

a method from the HttpUtils class should give me the full url but it
doesn't work for me.

On Mon, 10 Nov 2003 00:30:54 -0800, DaiIchi wrote:
> What class/package is getUserInfo() in? I viewed the page request over
> port 80 and didn't see the browser transmitting the username/password
> pair.... so I assume that it is inaccesible in an HTTP session. I hope
> I was wrong.


Ah, that explains it. I now know what you were proposing. But even
if request.getRequestURL() (for example) returned a URL object, the
getUserInfo() would have been meaningless. Try this:

import java.io.*;
import java.net.*;

public class test {

public static void main(String args[]) throws Exception {

ServerSocket ssocket = new ServerSocket(80);
Socket s = ssocket.accept();

InputStream is = s.getInputStream();
int ch = 0;
while ( (ch = is.read()) != -1) {
System.out.print((char) ch);
}
}
}
Run it... and then open a browser an type the URL:

http://somepretendusername@localhost

You should see:

GET / HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4)
Gecko/20030624
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plai
n;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

Notice how "somepretendusername" is *nowhere* in the browser-to-client
dialogue? So this portion of the username (and password) portion of a
URL is not passed to a web server in an HTTP exchange. Hence, Java
would have no way to even form a URL object with a working
getUserInfo() from the data above.

This is not a flaw of Java, as I said, it appears to be an issue with
the HTTP specification: even though username/password is a valid
formation of a URL, it isn't being passed by any of the browsers I
have (Mozilla or Internet Explorer). It would have been really useful
to me if it worked, though.


The way this works in HTTP-land is that the page is marked in the server as
password-protected, so it responds to the browser with a demand for
credentials for this "realm". At this point the browser should repeat the
request but with a name and password, and then getUserInfo() should work.

Check the documentation for your JSP software to see how you go about
password-protecting a page. Alternatively, consider passing the
identification info you want some other way, e.g. as a query string
(http://www.acme.com/?dailchi).

--
Chris Gray ch***@kiffer.eunet.be

Jul 17 '05 #7
On Tue, 11 Nov 2003 22:29:50 +0100, chris <ch***@kiffer.eunet.be>
wrote:
DaiIchi wrote:

.... <<SNIP>>...

Notice how "somepretendusername" is *nowhere* in the browser-to-client
dialogue? So this portion of the username (and password) portion of a
URL is not passed to a web server in an HTTP exchange. Hence, Java
would have no way to even form a URL object with a working
getUserInfo() from the data above.

This is not a flaw of Java, as I said, it appears to be an issue with
the HTTP specification: even though username/password is a valid
formation of a URL, it isn't being passed by any of the browsers I
have (Mozilla or Internet Explorer). It would have been really useful
to me if it worked, though.


The way this works in HTTP-land is that the page is marked in the server as
password-protected, so it responds to the browser with a demand for
credentials for this "realm". At this point the browser should repeat the
request but with a name and password, and then getUserInfo() should work.

Check the documentation for your JSP software to see how you go about
password-protecting a page. Alternatively, consider passing the
identification info you want some other way, e.g. as a query string
(http://www.acme.com/?dailchi).


You're right, of course... but the problem is that I don't *want* to
password protect the page--doing so will make the JSP server make the
determination of whether or not to reject the request. I'd like to
always give access to the request, but let the target .JSP file make
the decision based on the username/password passed in the URL.

Thanks for the help.

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: N.K. | last post by:
Hi, I'm using Tomcat 7.2 and I'm trying to deploy an aplication that uses JSP and servlets. I'm actually trying to duplicate a production server but can't get it right. In the directory...
1
by: Sascha Pohlmann | last post by:
hello, I have the following problem: I would like to evacuate the logic from my jsp files in servlets. servlets provide database contents prepared in HTML tables, the jsp files are supposed...
3
by: Jose Munoz | last post by:
Hi all, I want to share some data for all my applications (servlets and jsps). For this i am using a JSP to set the variables with scope=application. When i get this data from some JSP all is o.k,...
4
by: Peter Beck | last post by:
Hi - I have a question for someone who has experience with both ASP .Net and JSP/Servlets, relating specifically to thread safetly. In JSP, we say that instance vaiables of a servlet are not...
5
by: No One | last post by:
I have several years experience with Servlets under JSP and Components under ATG's Dynamo. Is there an ASP.Net equivalent to either?
1
by: samadams_2006 | last post by:
I hear a lot about Servlets running in Web Containers in the Java arena. I believe that the Web Container in question is the Web Server, like Apache Tomcat, or IIS in the .NET arena, but what...
3
by: Bit Byte | last post by:
I have written a custom servlet engine (and "wrapper" servlets) for some legacy code (C/C++) that I have. The servlets contain the bulk of my 1st 2 layers in a 3 tier architecture - i.e. data...
2
by: prakashsurya | last post by:
gud evening i need a help about servlets its a bit urgent actually the problem i am facing is when i use doGet method i am getting the result in servlets but when i am going for doPost i am...
0
by: ank99 | last post by:
hello...i m trying to run servlets(using GET) from wml page..... using apache tomcat 5.5 server and WinWap for Windows(version 3.2.1.28.)....its working fine as far as just to display wml form...
1
by: ank99 | last post by:
hello...i m trying to run servlets(using GET) from wml page..... web server : apache tomcat 5.5 server WAP Browser: WinWap for Windows(version 3.2.1.28.).... its working fine as far as just to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.