This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help for JSP?

 
Tony Tranquil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic