GeeCON Prague 2014*
The moose likes JSP and the fly likes Help for JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Help for JSP?" Watch "Help for JSP?" New topic
Author

Help for JSP?

Tony Tranquil
Greenhorn

Joined: Sep 23, 2003
Posts: 24
Hi all,
I working on a project, it provides functionality to upload file using JSP/Servlet. In the first JSP page, there is file location and submit button. After user select a file to upload and click submit button, a message, like "sending file to XXXX", will be shown on the screen. Once uploading and validation are done on the server-side, a successful/error msg will be shown to user.
Here I have a question for the "sending..." msg and the successful/error msg. They should be put in one jsp page or in two separate page? how to implement them?

Thanks for any help!
Baka Neko
Greenhorn

Joined: Dec 09, 2003
Posts: 14
Hey..maybe i can help ya out
I guess your fileupload page looks similiar to this one
<FORM METHOD="POST" ACTION="files.jsp" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILES" NAME="FILES" SIZE="50"><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
It then links to the "files.jsp" where all my uploaded files are validated.
If you got also a jsp file doing that for you, you can simply do something like this to show the messages you wanna show:
%>
<h1>Upload done!</h1>
<meta http-equiv="refresh" content="5; url='yournextpagehere.jsp'">
<%
You�ll get redirected to your next jsp page automatically.
Hope this will help you a little bit.
Cheers
Baka out
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Originally posted by Tony Tranquil:
Here I have a question for the "sending..." msg and the successful/error msg. They should be put in one jsp page or in two separate page? how to implement them?

Tony,
The decision to use one page for success and failure is entirely up to you, both will work. For example, if you use one page then you can use some form of flag to indicate which message to show.
e.g. (file - end.jsp):
----------------------
<%
if ( success ) out.print( "successful..." );
else out.print( "faliure..." );
%>
You can also at the time of success or failure decide to redirect to different pages:
e.g. (file - uploading.jsp):
----------------------------
if ( success ) response.sendRedirect("success.html");
else response.sendRedirect("failure.html");
I tend to prefere the latter method, where I can do the uploading etc inside the controller (ideally a Servlet) and then use RequestDispatcher or equivalent to forward to the appropriate view.
HTH


The secret to creativity is knowing how to hide your sources.
 
GeeCON Prague 2014
 
subject: Help for JSP?