1.) If user enters his username and password correctly, a login page (LoginPage.jsp) appears and says "welcome null" but it should show the name of that user instead of null.
2.) In that login page there is an edit button to edit profile information. When I clicked on it, every information is "null" and when I edit them and click on "Submit" button;
HTTP Status 404 -
type Status report
description The requested resource () is not available.
GlassFish Server Open Source Edition 3.1.2
that message appears.
3.) If I click on "Sign Up" button at the beginning, a registration jsp (SignUpPage.jsp) appears. After filling up text boxes and clicking on "Submit", same Status 404 screen appears.
I created a mysql database called "loginpage" using xampp. In that database there is a table called "users" and it has un, pass, name, surname, email and degree attributes.
Here is a screenshot of my project explorer:
Here is my code:
How come you are getting the as
This practically gets the session if it already exists, which at first (eg at the login page) there is no session. you should remove the false part.
Also in the jsp pages (those need authenticated content) add in the session attribute for the @page declaration
This way subsequent jsp pages will be session-aware until user logs out or session times out.
NewFile.jsp is just a form which you got. Yet those <@page import ....> can be removed at the top.
1) can just have the doPost() method. Because ideally this servlet won't be triggered by users typing it in the address bar.
2) don't need the explicit constructor. Remove that.
3) doGet() method can be removed.
1) add session="true" to <%@ page
2) why need to wrap "Hello...." in a form calling LoginServlet?
3) add line <% request.getSession(); %> before using session variable
That should get you started to a more simpler page/servlet.
Paul Ngom wrote:You want to display the name or the username? Because there is no field passed from LoginServlet on which you can apply a request.GetParameter(). Maybe you need to connect to the database to retrieve it. You could make LoginDao.validate() to return the name which you will attach to LoginPage as LoginPage?name=nameReturned. The values set in the session are un and pass.
I wanna display the name but I didn't understand what do you want me to do
status = rs.next();
This needs to be changed also otherwise you may never enter the while loop. I think an if clause is sufficient. This is in LoginDao.java
It is better to change the status variable value inside the loop like the following
If you do this, you can then call LoginDao.getName() inside LoginServlet.java
Then get the session value in the LoginPage.jsp
Hope i will be understood.
It was like;
before. And now it is like;
Still name attribute isn't displayed.
Try test it again and tell what happens.
That is why, i was asking that you give the possible values of the column degree in table. Run a 'select distinct degree from users;' in database and post the results.