I found a good article to upload a file using jsp here . I just modified it little so that it can upload file to the root directory of the webapp.
fileindex.jsp
<%@ page language="java" %>
<HTml>
<HEAD><TITLE>Display file upload form to the user</TITLE></HEAD>
<% // for uploading the file we used Encrypt type of multipart/form-data and input of file type to browse and submit the file %>
<BODY> <FORM ENCTYPE="multipart/form-data" ACTION="single_upload_page.jsp" METHOD=POST>
<br><br><br>
<center><table border="2" >
<tr><center><td colspan="2"><p align="center"><B>PROGRAM FOR UPLOADING THE FILE</B><center></td></tr>
<tr><td><b>Choose the file To Upload:</b></td>
<td><INPUT NAME="F1" TYPE="file"></td></tr>
<tr><td colspan="2"><p align="right"><INPUT TYPE="submit" VALUE="Send File" ></p></td></tr>
<table>
</center>
</FORM>
</BODY>
</HTML>
A blog about web application development mainly on backend side
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Thursday, December 27, 2012
Tuesday, December 25, 2012
jsp with beans example
Here is an example :
index.jsp
---------------------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="us" scope="request" class="msgbean.User"></jsp:useBean>
<%
if (request.getParameter("Name") != null) {
//out.write(request.getParameter("Name"));
us.setName(request.getParameter("Name"));
us.setEmail(request.getParameter("Email"));
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form method="post">
<table>
<tr><td>Name:</td><td><input type="text" name="Name"/></td></tr>
<tr><td>Email:</td><td><input type="text" name="Email"/></td></tr>
<tr><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>
You entered:<br />
Name: <%= us.getName()%></br>
Email: <%= us.getEmail()%></br>
</body>
</html>
----------------------------------
index.jsp
---------------------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="us" scope="request" class="msgbean.User"></jsp:useBean>
<%
if (request.getParameter("Name") != null) {
//out.write(request.getParameter("Name"));
us.setName(request.getParameter("Name"));
us.setEmail(request.getParameter("Email"));
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form method="post">
<table>
<tr><td>Name:</td><td><input type="text" name="Name"/></td></tr>
<tr><td>Email:</td><td><input type="text" name="Email"/></td></tr>
<tr><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>
You entered:<br />
Name: <%= us.getName()%></br>
Email: <%= us.getEmail()%></br>
</body>
</html>
----------------------------------
Subscribe to:
Posts (Atom)
What is DaemonSet in Kubernetes
A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...
-
Both .NET and NodeJS are popular programming frameworks that have their own strengths and weaknesses, which makes for an interesting compar...
-
A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...
-
In any software development process, it is crucial to understand the differences between various types of classes. Two such classes are ab...