can't write link to Get method using jsp - html

I wrote in my jsp page the next link:
Map
I want to send parameters to my controller (the controller is servlet).
BUT the problem is that in the browser it show's:
"http://localhost:8080/Attraxions4/Controller#/Attraxions4/Controller?pageName=OptionCategory&pageCommand=Map"
instade of:
"http://localhost:8080/Attraxions4/Controller?pageName=OptionCategory&pageCommand=Map"
what is this sign number #?
why it copy again the root folders?
what can i do to fix it ??
thank you!! :)

what is this sign number #?
It is a fragment identifier. It indicates the end of the part of the URL to send to the server and indicates the id of an element to scroll to.
It is often abused to store data for use with Ajax requests.
what can i do to fix it ?
Find the JavaScript you have that is hijacking the normal functionality of your links and remove it.

Related

Is it possible to put several URL in a href parameter?

I want to put a link with the <a> tag on my website page, but with multiple URLs in case the 1st one doesn't work. I would be something like this:
<a href="url1;url2;url3"
But of course this doesn't work. So is there a way to do this ?
Thank you
The closest you could come would be to:
Put a default URL in the href
List alternative URLs elsewhere (such as in a data attribute)
Bind a click event handler that runs some JavaScript which prevents the default behaviour and then tests each URL in turn until it finds one that works (or runs out).
Testing would require Ajax which would require either:
Permission via CORS from each URL you test
The user of a proxy (which would test availability of the URL to your proxy and not to the browser)
The additional HTTP requests would consume bandwidth (and thus time).
What do you mean by "1st one doesn't work" ? That the server is sending an error ?
It's not possible to do what you want just with HTML.
It could be done by Javascript by adding a listener to the anchor, sending HTTP request on the first url to see if you receive 200 or an error like 500.
In case of an error, you check the second url and so on and redirect the user where you received a 200.
Otherwise, if you just want to open all the links, there was already a post about that here: How can I open multiple links using a single anchor tag
There's no way of doing this with pure HTML since HTML can't detect whether or not what you mean by "doesn't work" applies to a given URL.

Is there a URL parameter that will make the URL open in a specifically named browser window

I have an email digest that is sent daily to users of my website and contains links to things on the site so that they can easily get right in and start interacting from their email. Trouble is, if they click more than one link, they're going to be opening more than one browser and the non-technical user might not catch that and end up having to close a bunch of tabs/browsers when they're done on the site. I want all the links in the email digest to be opened in the same window/tab.
I know that if you have an href you can set target=my_window and the links will open in that window. I'm wondering if there's a URL parameter that can be used instead of editing the a tag.
No. I don’t know of any browser (or other user agent) that associates any special behaviours with link query strings. The query string is for the server receiving the HTTP request to deal with.
As you say in your question, the target attribute is the method for controlling (or at least suggesting) what window the link should open in.
Can you use the window.open method?
Reference: window.open(url, name, features, replace);
It allows a browser window to be named, and thus reused when clicking on new links that are formatted to work with the window.open syntax.
Example: link
Status Update: Note you can search for many window.open(); Online Generators to help build the look of the opened window. It's important to test the desired look in all browsers, as the Address Bar in each browser is rendered differently.
The short answer is no. This behavior you are talking about is strictly client side, controlled by the browser. The application running on the web server is responsible for reacting to the query string.
Do you not have control over the template of the e-mails that are sent? It should be trivial to add the target to the appropriate anchors.
You can use PHP to catch custom URL parameters.
Say you have a link like:
www.yoursite.com/somepage.php?title=Some Page Title Here
The paramater string in the URL starts with ?something=somevalue and can be chained with the & symbol (e.g. ?something=somevalue&somethingelse=someothervalue) etc.
You can then ad this PHP to the top of your page:
<?php $title = $_GET['title']; ?>
Then for your title tag put the following:
<title><?php echo $title; ?></title>
You would add another variable with the value of the param for each param you want to pass in to the page. But for what you're trying to do, the above code will work.

how to go a portion of web page using a name attribute with querystring in URL

For example:
http://www.example.com/index.html#foo?key=value
When page is loaded, it goes to the bottom of the page. Any clue?
In HTML5 you just need to set the hash to an ID of any DOM node on the page and it should move the page down in the same way as old style page anchors.
Anything after the hash can only be accessed by JavaScript so if you want to get the value of key you will need some JavaScript to do so.
EDIT: Here is a good tutorial for storing and retrieving several attributes from the hash string - http://www.parorrey.com/blog/php-development/get-url-hash-parameters-values-using-javascript-for-php-_request/
You can read about anchor tags but you querystring is the wrong side of the hash. It should read:
http://www.example.com/index.html?key=value#foo

ASP.NET MVC: ActionLink vs bare url

In ASP.NET MVC I see I have handy HTML helpers that I can use to construct form fields and any number of other little things. But then there's 'ActionLinks'.
Why use an ActionLink instead of just writing the darn url myself in an HTML anchor tag?
In other words, why would I use
<%: Html.ActionLink("Back to List", "QuantityTypes") %>
instead of just using plain ol' HTML and writing:
Back to List
Surely, I must get something extra with the ActionLink. I'm just missing it, right?
The action link will build you the proper URL based on the controller, action, areas, params, etc... It generates the URL based on the URL mapping rules defined in the your MVC routing system. It will map params to the correct url as well depending on if it needs to be included in the URL directly or via a querystring param.
Yes you could do it on your own and just type it all out but it builds the URL for you and ensures the URL that is generate is correct. It's a helper function... it helps you produce valid links :)
You should read Scott Guthrie's post and pay extra attention to the section "Constructing Outgoing URLs from the Routing System". It gives the why and explains other helpers that leverage the routing system.
You get centralized control of your URL's. So next time you need to change one for SEO purposes, you don't have to go searching for every place in the application, just switch it in the Global.asax.
What if you wanted to change the controller name from Internal to External. What is going to happen? You are going to need to change the href link by hand. ActionLink will do automatic routing. You don't need to mess with urls.
Another reason for using ActionLink over bare url is that you may need to expose a download link to a secured resource that can only be accessed by the application through identity impersonation.

How can I post data (form) to html page and hijacking the data in the middle?

the site addres: http://www.ynet.co.il/YediothPortal/Ext/TalkBack/CdaTalkBack/1,2497,L-3650194-0-68-544-0--,00.html
fill the form with rubbish.
Hit 'Send'
the form post the data to another HTML without any parsing of the data i've just added
How do they do it?
A likely option is that they are using a content management system where "html" on the URL doesn't actually mean it's a static html file.
This may be out of left field, but I've certainly used the occasional JS function to grab everything in the header and either parse it or pass it to another script using AJAX.
I'll sometimes use this method in a 404.html page to grab the headers of the previous page, parse them out to see where someone was trying to go and redirect them.
That is, as annakata said, one of the numerous options available.
Edit based on clarified question:
Numerous frameworks can be configured to intercept an html request - for instance asp.net can be set to handle any given extension and an HTTPModule could do anything with that. It's really up to web server configuration what it decides to do with any request.
also: you don't really want to be saying "hijack"