aspose file tools*
The moose likes Servlets and the fly likes How can i use message window in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can i use message window in servlet" Watch "How can i use message window in servlet" New topic
Author

How can i use message window in servlet

Rupa Katkar
Ranch Hand

Joined: Aug 12, 2009
Posts: 35
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

Joined: Feb 19, 2008
Posts: 2902
    
    1



Never tried this code, but give it a try .


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Rupa Katkar wrote:Please reply me urgently......

EaseUp
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Aug 12, 2009
Posts: 35
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

Joined: Aug 12, 2009
Posts: 35
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 12, 2009
Posts: 35
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i use message window in servlet