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?
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
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.