Basically, I have a jsp page that when loaded will redirect the user to another URL (google.com for example). The problem I'm running into is the URL that the user is being redirected to has it's own authentication, and I'm trying to avoid the user needing to login with different credentials (I dont want to give them my UN & PW)... Is there a method or a way to hard code the username and password in the code so that it is used during the redirect?
This is what I'm doing right now:
<html>
<head>
<meta http-equiv="refresh" content="0; URL=https://www.google.com/" />
</head>
<body>
<p>Please Wait...</p>
</body>
</html>
Thanks in advance for your help!
Shawn
If the redirect is to another page of your site, store user information as you can in the session and use it on another page:
Session training
https://www.w3schools.com/php/php_sessions.asp
If you do not want to use PHP, you can send the information using the Get Address method and encode the information with one of the algorithms, but this method is not recommended !!
(I can not write good English)
Related
I want to make chat program. But when I click submit http is
reset "localhost:3000/" to "localhost:3000/?"
Why http reset and append address ?
if i don't use server just run index.html also
file:///C:/Users/dude/Desktop/node/index.html?
this is index.html code
<html>
<head>
<title> chat with node js socket io </title>
<style>
#chat{
height:500px;
}
</style>
</head>
<body>
<div id="chat"></div>
<form id="send-message">
<input size="35" id="message"></input>
<input type="submit"></input>
</form>
</body>
</html>
I think you need to be a bit clearer on your information here.
Are you sure you want to submit the whole page? I think what you are looking for is not posting the information with the whole page, which is what the form and submit will be doing.
If you use AJAX, you will only be sending the information you need, not the whole page, and update accordingly.
The "?" is part of the querystring, and should not affect the workings of your sofware. It is hinting that it is trying to do a "GET" with the form, which is the default behaviour. Do you have anything listening for the "GET" on the server?
I suggest to follow the standard HTML conventions in forms, by adding name attributes to your inputs, a URL where your form should be posting to ("action" attribute). Once you have standardized your HMTL, the next step would be to look at your functionality requirements. E.g. do you have your server functionality in place, where the chat info will be sent to?
So I have a website which redirects to another part of the site ie, when pressing a button on "www.test.com" it reditects to "www.test.com/anotherpage". Now my problem is that I only want users to be able to access the second page when using the button and not just typing in "www.test.com/anotherpage" into the search bar.
So, is there any way to setup my page such that it cannot be accessed by the url but only redirected from another part of the website?
document.referrer
The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page.
You need use Php code to login users and check sessions example like exaplain here: Login form and session example
of course you need basic know about Php
You could use a client or a server side technique.
Example of client side is Javascript, reading the document.referrer in the called page as #Barmar pointed out, and redirecting to the home in case the referrer is not from your home page.
The server side way could make use of parameters passed to the page, like a SESSION identifier that will be generate on the home page, for example and checked in the called page.
Actually there are a different ways to accomplish your goal.
You should provide some more info about the environment so we can help.
You can usee PHP. Simply put your button between form tags
<form action="http://www.test.com/anotherpage" method="POST">
<input name="mybutton" type="submit" value="Go to another page">
</form>
and on anotherpage
<?php
if (!isset($_POST['mybutton'])) { //check if the button was clicked
header('Location: index.html'); //forward to index if not
}
?>
Ok, so I have been extremely so confused on how to solve that.
I have a main page called 'index.html'. It has a button that says "create account" that allows you to make an account, and another button that links to sign in page if you already have an account.
After you make an account when you sign in it will take you to a page called 'browse.html' where you can see all the movies you can watch.
I just can't figure out how to redirect people that try to access 'browse.html' from the URL to the sign in page. So like say you don't want to make an account, you could just type in the URL for the 'browse' page and not have to create an account. I tried below code
<meta http-equiv="refresh" content="0; url=(my sign in page)">
in the header of 'Browse' page, but that creates a loop that will never allow people to see the 'browse' page movie list.
I'm not good at explaining this, but I hope you can understand what I am trying to say.
you can use the php SESSIONS for that
first set the session variables in login and redirect to the browse page then check on browse page that if session has that variables then they can view the page else redirect to login page
for more info on sessions
go to http://ww.php.net and search for sessions
In my JSP page I am using post method while submitting the page.
So once I go from Page 1 to page 2. In Page 2, If I press F5 I am getting alert as
"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."
I knew this question is a bit sarcastic but please give me an Idea.
I can't change my method from POST to GET because I need to send large amount of data.
Thanks in advance...
Edited:
In my Page1.JSP I call onClick function in that function I call action as "/page2servlet.do".
Now, In Java side I use Spring Framework. With MVC Object I return to page2.jsp.
So where do the response.sendRedirect Fit.
Do a redirect to Page 2 after POST. You will not receive the prompt anymore.
After doing POST save all the info you will need to session and send an instant redirect to other page with GET. Then on that other page get all the info you need from session.
However, after the session expires user wont be able to press Refresh. Also, it will break multi-windowing. User won't be able to do 2 distinct submits in separate windows as they will share same session object.
<?php
session_start();
if(!isset($_SESSION['disablethispage'])){
$_SESSION['disablethispage'] = true;
// serving the page first time
}else{
// visited before or page was refreshed
}
?>
Here is a version that replaces the next page:
http://plungjan.name/testredirect.html ->
redirect.php ->
thanks.html
and here is redirect.php
<meta http-equiv="refresh" content="3; url=http://plungjan.name/test/thanks.html">
<script>
location.replace("http://plungjan.name/test/thanks.html");
</script>
redirecting..
.
I want to to connect to another page after logging in HTML.
For example I have my login page when I submit my information (username, password) I have an action for my login and I want to go to another page when my Authentication is true.
I don't have acces of the code of the server, server using jps
Try with:
<meta http-equiv="refresh" content="0;url=http://example.com/" />
or
<?php header( 'Location: http://example.com/' ) ; ?>
When you authenticate user
It depends what language you use in the backend.
If you do only javascript validation of the login, you should drop this logic and rewrite it using a proper backend language (php, .net, rails, or whatever), since it would be a huge security problem.
Example of redirection using Ruby on Rails:
redirect_to "yourpath"
using PHP:
header("Location:yourpath");
If you are using form in jsp or html you can use the folowing code,
<form name="frm" method="post" action="sec.jsp">
This will direct to sec.jsp. You can also use servlet mapping if you are using servlets.