How to make a simple Login page using Servlet & Session in NetBeans IDE

preview_player
Показать описание
How to make a simple Login page using Servlet & Session in NetBeans IDE

1. Open NetBeans IDE

2. Make a new Project as:

2.1 File~NewProject~Java Web~WebApplication

3.1 RightClick on Source Package~New~Other~Web~Servlet
3.2 Name your Servlet

5. Make an HTML file as:

5.1 RC on Web Pages folder and select New~Other~Web~HTML
5.2 Design a simple form in HTML
5.3 Give the url-pattern of First Servlet in the 'action' attribute(say '/First')


6.1 In this servlet set the session attribute with a 'key' and its 'value'.

7.1 In this get the attribute of session.

8. Run the Project(let server is Tomcat).

9. Finish.

Follow us on :
Рекомендации по теме
Комментарии
Автор

Thank you so much for the clear information that you show here raksrahul!!
It helps a lot for the new persons (Like me) who are being introduced to Java!

alvaroartechemartinez
Автор

realy great tutorial, been looking for this.

Would be cool if you could make one where the user signs up to the website and the website creates a profile for the user then the user can log into that profile. Thanks

assaultwoolf
Автор

Thanks for your like, comment.
I will think about your suggestion.

raksrahul
Автор

it was great tutorial i am new to jsp n servlet and trying to develop my project. Can we write database connections and session in same servlet(data from webform will get insert into database and session will take us to another page )???

Hiteshheavens
Автор

while running, i got an error stating "Deployment error: Starting of Tomcat failed.
See the server log for details.", it would be pleasure if u help me in solving this..tq.

assrikanth
Автор

I would like it more if there is voice over

hienlong
Автор

/**
*
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {


Dude, in the long run your code won't work if you don't put this you need to send "post" method to the servlet..
Replace above code to First.java and as well as Second.java

Then it will work..

.Thanks for your video :) cheers

senadheerashan
Автор

during login, I am getting the error as HTTP Status 404 - /login/login.html.... can you please help me to resolve the error as soon as possible..

preetivashisth
Автор

Deployment error: Access to Tomcat server has not been authorized. Set the correct username and password with the "manager-script" role in the Tomcat customizer in the Server Manager.
See the server log for details.
BUILD FAILED (total time: 5 seconds)

this error is come

asthagaur
Автор

i need logout servlet session with  validation buddy

chaitanyagudela
Автор

I'm sure that it must be a great tutorial, but not having a voice to explain is a turn off.

programmingjo