Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i use message window in servlet

 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing Login page---in that if Authentication is failed,
I want the to give some message to user that he is failed to login & login once again
for this purpose i want message window in servlet/java.

Please reply me urgently......
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Never tried this code, but give it a try .
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rupa Katkar wrote:Please reply me urgently......

EaseUp
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rupa Katkar wrote: i want message window in servlet/java.


you should not display this message[authentication fail message] on servlet ,it consider poor practice . validate on servlet[using java class] set the message in request scope[any one of the scope] and forward it to the login page(jsp) and display it on jsp.
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:
Rupa Katkar wrote: i want message window in servlet/java.


you should not display this message[authentication fail message] on servlet ,it consider poor practice . validate on servlet[using java class] set the message in request scope[any one of the scope] and forward it to the login page(jsp) and display it on jsp.


I made the validation, but when user fails to give correct username/ password, we
should give some chance to reenter know, for this purpose i want the message window to display
that please re enter the details..
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:

Never tried this code, but give it a try .



I want to give more trials for re-entering the username / password,
For this purpose i want the message window.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's wrong with the code or suggestions you were given?

You can't do anything on the server side except return something to the client, like a message, a flag indicating a dialog should open, etc. I don't really think opening a window to simply display a failure message is appropriate--just show the message on the page.

What, specifically, are you having trouble with?
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:So what's wrong with the code or suggestions you were given?

You can't do anything on the server side except return something to the client, like a message, a flag indicating a dialog should open, etc. I don't really think opening a window to simply display a failure message is appropriate--just show the message on the page.

What, specifically, are you having trouble with?


After showing the message using the window, I want it should again open the Login.jsp page.

I did like this
....
out.println("<script type=\"text/javascript\">");
out.println("alert(\"Please reenter the username/Password\")");
out.println("</script>");

RequestDispatcher dispatcher = request.getRequestDispatcher("/Login.jsp");
dispatcher.forward(request, response);
....
But what happening here, its not showing the alert, its directly going on Login.jsp page.


The thing is that i am new to jsp & all thats why i am facing so much problems..
Please help me.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should back up a step and bring yourself up to speed on JSP and Java webapps in general, otherwise you're going to end up with a solution you don't understand, can't maintain, etc. Check out some of the tutorials on the Sun website and around the web.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rupa Katkar wrote:
out.println("<script type=\"text/javascript\">");
out.println("alert(\"Please reenter the username/Password\")");
out.println("</script>");

To avoid writing HTML code in servlet we use JSP, so what you really need is incorporating this code in login.jsp which get displayed when some bean, flag is set, as I shown in my first reply.

And get your JSP basic clear first, Google for JSP/Servlets tutorials. :thumbup:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic