This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 247
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64606
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ram Narayan.M,

for your opnion


Thanks a lot Bear Bibeault,

for making it more clear and easier
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic