This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes action atttribute and difference between style of giving path of a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "action atttribute and difference between style of giving path of a servlet " Watch "action atttribute and difference between style of giving path of a servlet " New topic
Author

action atttribute and difference between style of giving path of a servlet

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
style 01

<form method ="get"action="http://localhost:8080/rootam/Myname">

style 02

<form method ="get"action="Myname">


i want to know what "techinal term" a progrmmer should use for the first style of giving path , when we should use it ???
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

style 1 refers to the full path of the resource...
style 2 refers to the relative path of the resource..

In style2, action URL is resolved on the basis of current Request URL of the Page in the browser.

For instance,

http://localhost:8080/root/html/form.html contains "<form method ="get"action="Myname">"

action="Myname" The URL in this is resolved as "http://localhost:8080/root/html/Myname" by the browser which leads to Resource not found by the server...

To refer to Servlet, Style1 (Full path of servlet) is advisable..


SCJP 6 [SCJP - Old is Gold]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Ram Narayan.M wrote:style 1 refers to the full path of the resource...
style 2 refers to the relative path of the resource..

Not completely correct. The first is the absolute URL, the second is the page-relative URL.

The former is used to address resources in other domains, the latter should never be used.

Rather, resources in the same web app, or from the same domain, should be addressed using server-relative addressing which begins with the context path of the web app.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
Thanks Ram Narayan.M,

for your opnion


Thanks a lot Bear Bibeault,

for making it more clear and easier
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: action atttribute and difference between style of giving path of a servlet
 
Similar Threads
How to check if textboxes are null
struts 2 -- name matching when we retrieve attributes from Action class
Submit HTML form Data thru Servlet
How to hide the parameters in the URL??
adding a servlet