• 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Copy paste link should get redirected to home page.

 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am developing a webpage using servlets. main page This is my main page, with simple sing-up and sign-in form along with forgot password. So when i try to reset my password password-reset link, when i try copy paste the link from fire-fox to chrome browser the page is getting displayed. But I want the home page to be displayed.

Is it possible to do like have if else in the following code so that copy paste link from one browser to other browser displays home page.

 
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course. It's the responsibility of the servlet to decide what should be done with the request. If it has to decide to forward to different JSPs based on the content of the request, or indeed based on other information, then it should do that. As for whether you can use if-else statements, bear in mind that servlets are written in Java and they can use any and all features of the language.
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, your links to localhost:8080 aren't going to be helpful to anybody who isn't sitting in front of your computer. We would need an address which is visible from anywhere on the web. But don't spend any time on trying to make that happen because it's going to be very hard and just cause problems. Instead, try explaining in a different way.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So this is my reference. Here only I have to change RegisterServlet instead of ForgotPasswordServlet. Do i need to add any fields to the a tag so that I can differentiate what jsp page to be accessed?

This is in my RegisterServlet.java file
 
Saloon Keeper
Posts: 6027
154
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What information do you think you need? Something called "ForgotPasswordServlet" surely should not forward to a JSP called "Register.jsp", should it?

The name to be used for the request dispatcher should be something like "/WEB-INF/ForgotPassword.jsp".
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See Forgot password will generate a link which i can access to reset my password. But by copying the link and pasting the link in different browser displays me the exact page. Its not secured right. So when the user do copy paste the link the link should refer to the main page. Hope I am clear.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once we logged-in to our g-mail account, and when trying to copy paste the link in different browser it will display the main page of g-mail. Like that I am trying to do.
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, forget about this copying and pasting business. You have a web page page for resetting a password? Then your next step is to decide what the controller servlet should do.

Perhaps it should behave differently based on whether the user is already logged in? If that's the case then you should expect it might behave differently if you take a link from a place where the user is logged in and paste it into a place where the user isn't logged in. That's why I say that your copy-and-paste issue isn't an issue, or rather that it shows you haven't got your design right yet.

 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean I need to do check whether the user has logged in or not?
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 Jsp code

Servlet code



In the above code its displaying empty page without any error.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet code



JSP code



Its not getting in my if statement. Instead coming to my else. Where i am wrong. Please help me.
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gayathri Gayu wrote:You mean I need to do check whether the user has logged in or not?



Well yeah, of course. How can you reset a password if you don't have a logged-in user? That's what I mean when I say you have to decide what the servlet is supposed to do.
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


That comparison can never be true.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The above is my jsp code for register, sign-in and forgot password, which the forgot password is referring to ForgotPasswordServlet page. Whether the user have logged in or not he is getting redirected to the reset password page directly if he know's the link.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

That comparison can never be true.



So how will I do the comparison?
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the servlet you are going to examine the request and act accordingly based on what it contains. So yeah, comparing two different strings is pointless. Don't you have to get something from the request?
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have two different servlets which the sign-up and login access one servlet and the forgot password access different servlet. So how it will act accordingly? And yes I should get something when i do request.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet code



JSP code


The above code works for me. But again copy paste the url /webaddress/RegisterServlet?action=forgot-password in different browser is displaying empty page. But i want it to get redirected to main login page.
 
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I type that url into a browser then what do you want the servlet to do?
Where do you want it to go?
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I paste the url from fire-fox to chrome browser it should redirect me to the home page. Instead of displaying empty page. Is it possible?
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget pasting.
That's a red herring.

What happens if I open my browser and type that URL in.
What should happen?
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See when you logged in and its displaying the url /webaddress/RegisterServlet?action=forgot-password address in a browser, and when you try to type the same url in different browser it should re-direct to home page as you haven't logged in in that browser. Hope I am clear.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple example. logged-in I have logged-in with my mail id. And when i try to type the same link in another browser, the session was logged out displaying the same page.
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would anyone who had successfully logged in want to use the "forgot-password" functionality?
They're logged in!

Surely you want people who hadn't logged in to be able to access that page?
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Why would anyone who had successfully logged in want to use the "forgot-password" functionality?
They're logged in!

Surely you want people who hadn't logged in to be able to access that page?


If in case I forgot my password I have to reset right for tat purpose I have forgot password feature
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgotten password functionality is for people who have forgotten their password.
That would mean these people have not logged in.

So preventing someone from getting to the "forgot password" page unless they are logged in would not be very useful.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok let us leave the forgot password link. What about for uploading files page once we login and go to file upload page, that page url is getting displayed in the different browser.
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Why would anyone who had successfully logged in want to use the "forgot-password" functionality?
They're logged in!

Surely you want people who hadn't logged in to be able to access that page?



Oops, sorry, that was my fault. I confused "reset password" with "change password".
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gayathri Gayu wrote:What about for uploading files page once we login and go to file upload page...



I would suggest that file uploading is not a good topic for servlet beginners. Too many complications.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still I would like to do that and I added a page but when typing the file upload url on different browser its displaying the same page. I want it to display the home page. Let me know how to achieve this please.
 
Paul Clapham
Marshal
Posts: 24926
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going to suggest that you show us the servlet code. But I expect you have a whole lot of code related to file uploading, which is unrelated to -- whatever your problem is with those browsers. So could you just write a simple servlet which does almost nothing except to forward to the home page, which seems to be what you want to do. If that doesn't do what you want, then you've got something to post here and ask your question about. If it does do what you want, then start adding code in small quantities untill it stops doing what you want. Then you'll have something to post and ask about.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is the servlet code for sending mail.



code for sending mail to the person who requested reset password. Here the generated link when i do copy paste from a browser to the other one the same page with the change password fields getting displayed. Instead it should display either access denied message or the main page with the access denied message.
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on your previous threads I'm going ot assume you have hand coded your login/security code.
This here is why people were suggesting you not do that and instead learn how to use the pre-packaged security code that comes as part of JEE.

A lot of these issues are handled by that, but now you are in a place where you have to solve the exact same problems.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is pre-packaged security code that comes as part of JEE. ? I am using java servlet and mysql.
 
Gayathri Gayu
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://localhost:8080/RegistrationMvc/PasswordUpdateServlet?tokenId=d66c7638-09df-4a0a-96bf-fe8243277a94" This is my generated url to reset my password. So if someone copy the url or typing the url in their browser the password reset page will open so they can change the other users password as the original user mail id i am getting directly to the email field, which is dangerous to the original user. This is what i am asking how to display a access denied message for accessing the url directly.
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't.
It's a password reset.
I mean, I assume that's what appears in an email?

How do you expect the user to open the web page in a browser if the can't access the page via the supplied url?
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!