File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Difference between URLs: /? and /login? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Difference between URLs: /? and /login?" Watch "Difference between URLs: /? and /login?" New topic
Author

Difference between URLs: /? and /login?

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Hi!
Could some one explain the difference between the following urls?
www.example.com/? and www.example.com/login?
Thanks!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Faisal,
One goes to the server root and the other goes to a path. I don't think I understand the question.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Thanks for replying!
Well, my question is:
? separates the path and parameters. For this url: http://www.example.com/login?fs=1&view=tl it is very clear that we are passing parameters to "login" servlet.
I didn't understand this url: https://mail.google.com/mail/?fs=1&view=tl Here to whom are we passing parameters?
Thanks in advance for your help!
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Faisal.
In the web application scenario,
www.example.com/
is server root, and
www.example.com/login
is application root.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Faisal.
In
https://mail.google.com/mail/?fs=1&view=tl
I think gmail application adds these parameters and redirects it to the client. Then the client is sending request to the server with these parameters.
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Chinmay!

Thanks for your reply. Could you please elaborate?

Thanks again!
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Faisal.
I think in gmail application, the redirection happens like this(this is my assumption, there may be better approaches than this),

Here attributes 'paramOne' and 'paramTwo' are set some where in the application.
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
Chinmaya Chowdary wrote:Hi Faisal.
I think in gmail application, the redirection happens like this(this is my assumption, there may be better approaches than this),

Here attributes 'paramOne' and 'paramTwo' are set some where in the application.


I do not think this explanation is correct; it still did not explain why thhe url appears as
https://mail.google.com/mail/?fs=1&view=tl

If a redirect had occured to the mail page, one would have expected some thing like
https://mail.google.com/mail?fs=1&view=tl

I am not buying your explanation yet.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Anselm.
I am sorry, here 'value' attribute of <c:url > tag is not '/mail', it is '/' in <c:url > tag.
In
https://mail.google.com/mail/?fs=1&view=tl
the part
https://mail.google.com
signifies server root, the part
/mail
signifies application root, and the part
/?fs=1&view=tl
signifies query string.

Now we are in 'mail' web application, and one of its jsp wants to do redirect, and it can be done by
.

In the above code the JSTL's <c:url >tag is used for URL rewriting and URL encoding. At the end it produces
/mail/?fs=1&view=tl
with 'jsessionid' if the client disables cookies(like /mail/;jsessionid=...) and sets the attribute 'var' in page scope like,
Here the values '1' and 'tl' are produced by 'paramOne' and 'paramTwo' that are set some where in the application.

Now we have to get the attribute 'var' that was set in the page socpe. It can be done by Now we have the URL and we are about to redirect it by using response object's sendRedirect(String str) method, like Now the redirection wil happens. During redirecting, the client(browser) sends the request to the server by using the url
Now the DD checks the url pattern, here it is '/'(default servlet) and finds the appropriate servlet and sends the parameters 'fs=1&view=tl' to it, process it and finally the response will be sent to the client.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

For me, the only difference between www.example.com/login/? and www.example.com/login? is that the first one will map to a servlet mapped to /login/* and the other one is mapped to /login. So basically both the paths can map to a servlet (this is of course if the application on this domain is mapped to ROOT)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Chinmay!
Thanks for your explanation and time.

Ankit!
Thank you.

Both of your replies helped me a lot in clearing my doubt.

Chinmay, I just came to know you've recently passed SCWCD. That was a great score. Cheers!

Thanks again!
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Thankyou Faisal.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between URLs: /? and /login?