• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

With and without /  RSS feed

 
Ranch Hand
Posts: 212
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple question:

Whats the difference between

and


 
Saloon Keeper
Posts: 10136
214
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first is a path relative to your current page, while the second is a path relative to the root of your application.
 
raja singh kumar
Ranch Hand
Posts: 212
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the second is a path relative to the root of your application.



Example is the name of my project and also the context root. I am using websphere server which uses 9080 as the default port. I have mentioned the form tag with action in my html file.

I access my html form as:

http://localhost:9080/Example/index.html

When I mention / in the front in the action attribute like this (/a), on submission of the html form the url becomes

http://localhost:9080/a

How are you saying it is a path relative to the root of the application? The root in the case of this application is Example, but that disappears on the submission of the form.
 
Marshal
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a Java web application, URLs should start with the context path, which you can obtain programmatically in your JSP or servlet. See the JspFaq for more info.

As you have noted, without it, the "/" makes the URL relative to the server, not the web application.
 
Stephan van Hulst
Saloon Keeper
Posts: 10136
214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, my apologies, I meant the server.
 
raja singh kumar
Ranch Hand
Posts: 212
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gone through the JSP Faq

So when I use / at the starting of the url in the action attribute of the form, it is a server-relative path?

When I dont use / at the starting of the url in the action attribute of the form, it is a page-relative path?

Please correct me if I am wrong.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as you shown the

1.<form action ="url">

is called An absolute URL which normally indicates current url and

2.<form action = "/url">

is called  A relative URL which indicates the root of the application url.
 
Sheriff
Posts: 24380
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Purvi Barot wrote:as you shown the

1.<form action ="url">

is called An absolute URL which normally indicates current url and

2.<form action = "/url">

is called  A relative URL which indicates the root of the application url.



Purvi, it's fine to reply to old posts when you have useful information to add. But a post like this one, which is completely wrong, maybe you should think twice before posting it?
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
ScroogeXHTML - the small and fast RTF to HTML converter library
https://coderanch.com/t/707504/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!