Form with Error Checking : Form Input Data « JSP « Java Tutorial


<HEAD><TITLE>Implicit Object Project</TITLE></HEAD>


<FORM METHOD="POST" ACTION="StreamResponse.jsp">

<H2> Streaming file demo </H2>

 <TD> Enter File name: </TD>
 <TD> <INPUT TYPE="text" SIZE=60 NAME="File"> </TD>
 <TD> Enter optional MIME type: </TD>
 <TD> <INPUT TYPE="text" SIZE=30 NAME="MIME type"> </TD>


<INPUT TYPE=submit VALUE="Fetch">
<INPUT TYPE=reset VALUE="Reset">




<%@ page isErrorPage="true" %>

<H3> Error occured: <%= exception.getMessage() %> </H3>
<%@ page import="*" errorPage="StreamError.jsp" %>
    String filename = request.getParameter("File");
    String mime_type = request.getParameter("MIME type");

    if((mime_type != null) && (mime_type.length() > 0)) {
       response.setHeader("Content-Type", mime_type);  

    String line = null;
    BufferedReader iread = new BufferedReader(new FileReader(filename));
    while((line = iread.readLine()) != null) {

  Download: 4 k)

23.25.Form Input Data
23.25.1.Use Loop to Read Form Controls
23.25.2.Use For Each to Loop Through all Values Passed in by Form
23.25.3.Read Hidden Control in Same File
23.25.4.Pass Form Value to Bean
23.25.5.Form with Error Checking