Gayathri Gayu

Ranch Hand
+ Follow
since Feb 25, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
8
Received in last 30 days
0
Total given
14
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gayathri Gayu

Swastik Dey wrote:

Try to access this page without logging in or from a different browser after logging in.  

In the above line we are retrieving the userinfo from session.  If the value is not null we show the page.  It will be not null only when the user comes to this page after logging in because there only you are setting the user info in session, if the url is opened from any different browser instance it will be null.



I want the same to happen in FileUploadServlet page where my jsp code is

How will i restrict the access of this page.
1 month ago
I tried printing my echo $CATALINA_BASE and echo $CATALINA_Home which returns empty. So what should i do before configuring the realm? Please guide me.
1 month ago
And yes my user information is stored in mysql database.So I should use JDBCRealm and DataSourceRealm. ?
1 month ago
So do I need to do the Realm configuration so that the authentication will be done?
1 month ago
Please tell me how to use AuthenticationFilters in web.xml and write a method to authenticate every request whether it is valid or not.
1 month ago
I browsed in net and got the following code of web.xml



Will this do the authentication and restrict accessing pages?
1 month ago
I have created a simple login page which in turn redirects to the list of file contents. I do have three separate servlets. LoginServlet, LogoutServlet and FileUploadServlet. Where the Login and Logoutservlet redirects to the main page. But the FileUploadServlet will display the page with the two text fields along with a file upload. When the user type the url with the FileUploadServlet name directly the page loads without logging in. How to restrict accessing this. Please help me.
1 month ago
And the login button click will access the LoginServlet class. But then when i click add it is accessing the FileUploadServlet class in which when the user without logged in can access the page easily.

jsp code for uploading file.

Java code for file upload. When i try adding the same line in jsp file it returns null. So how will i access the userName in all pages?
1 month ago

Swastik Dey wrote:

Try to access this page without logging in or from a different browser after logging in.  

In the above line we are retrieving the userinfo from session.  If the value is not null we show the page.  It will be not null only when the user comes to this page after logging in because there only you are setting the user info in session, if the url is opened from any different browser instance it will be null.



Thanks for the code. That works. But when trying to access from different browser instead of invalid access error message i go the HTTP method GET is not supported by this URL error message.
1 month ago
Sorry to ask. But i am not able to understand.
1 month ago
That one line code is enough for tracking the session? As I have a admin page in which the login page loads the following code which calls FileUploadServlet.java And when i open the same page in after logout or in different browser the page display the content.

1 month ago
The above is the servlet code where the user login.

This is where we check the entered username and db user name same. Where should i put the user info in session attribute.
1 month ago
Please tell me how will I access the session?
1 month ago

Tim Moores wrote:A page called loginservlet should not display content. That should be done by whatever page serves content according to the user's permissions. Are you maybe not doing a post-redirect-get after login?

And yes, why does the content page display something to a user who is not properly authorized?



How will i do the authorization?
1 month ago

Swastik Dey wrote:Does session tracking help in this?

How will I do that?
1 month ago