Learning Process of a Jsp beginner (8)
TheUnforgiven
Chapter 8 operations on image files-accessing and using the first Servlet of Blob Data
I found some information on the Internet and adapted the following code based on my requirements:
------------------------------Upphoto.htm ------------------------------------
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> untitled document </title>
Head>
<Body>
Upload images:
<Form name = "form1" method = "post" action = "upphoto. jsp">
<Input name = "id" type = "text">
(Enter an integer as the ID of the image) <br>
<Input size = "50" name = "file" type = "file">
<Br>
<Input type = "submit" name = "Submit" value = "submit">
</Form>
<P> & nbsp; </p>
<P> & nbsp; </p>
Show image: <br>
<Br>
<Form name = "form2" method = "post" action = "showphoto. jsp">
<Input type = "text" name = "vid">
(Enter the ID of the image) <br>
<Input type = "submit" name = "Submit2" value = "submit">
</Form>
</Body>
</Html>
---------------------------------------------------------------------------
Upphoto.htm includes two <form>: form1 is used to select the image to be saved in the database; form2 is used to display the image in the database.
----------------------------- Upphoto. jsp ----------------------------------
<% @ Include file = "include. inc" %>
<% @ Page contentType = "text/html; charset = gb2312" %>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">