Problem in request object

Problem in request object

I have created a form where I have file input along with other inputs. I am using jsp to process the inputs. File input is not processing while the rest of the data is being processed.Please Help me out!!! Here is my code:

<html>
<head>
<title>
</title>
<link rel="stylesheet" type="text/css" href="css.css" /> 

</head>
<body>
<LINK REL="SHORTCUT ICON" HREF="favicon.ico">
<link rel="icon" type="image/gif" href="favicon.gif" >
<div class="box">
<div class="header">
<table>
<tr>
<td>
<img src="images2.jpg" width=150px height=80px style="margin-left:5px; margin-top:5px;" />
</td>
</tr>
<tr>
</tr>
</table>
</div>
<div class="content">
<center>
<form name="myform" method="GET" enctype="multipart/form-data" action="home.jsp">
        <table border=1 style="margin-top:5px;">

            <tr>
            <td colspan=2>
            � � � � 
            </td>
            </tr>
            <tr>
            <td>
            <b>
            Attachment:
            </b>
            </td>
            <td>
            <input type="file" name="file1" value="file1" size = 20 style="text-align:left;">
            <br />
            <br />
            </td>
        </tr>
        <tr>
            <td>
            <b>
            Application:� � 
            </b>
            </td>
            <td style="text-align:left;">
            <select name="application">
            <option value="gasper">Gasper</option>
            <option value="aptravision">Aptra Vision</option>
            <option value="CM">CM</option>
            <option value="ESR">ESR</option>
            </select>
            <br />
            <br />
            </td>
        </tr>
        <tr>
            <td>
            <b>
            Region:� � 
            </b>
            </td>
            <td style="text-align:left;">
            <select name="region">
            <option value="amer">AMER</option>
            <option value="emea">EMEA</option>
            <option value="cla">CLA</option>
            <option value="apac">APAC</option>
            <option value="walmart">Walmart</option>
            </select>
            <br />
            <br />
            </td>
        </tr>

        <tr>
            <td>
            <b>
            Description:
            </b>
            </td>
            <td style="text-align:left;">
            <textarea name="description" rows=6 cols=20>
            </textarea>
            <br />
            <br />
            </td>
        </tr>



        <tr align="center">
            <td colspan=2>
            <input type="submit" value="Submit"  name="submit">
            <input type="reset" value="Reset" name="reset">
            </td>
        </tr>
        </table>
</form>
</center>
</div>
<div class="footer">
</div>
</div>
</body>
</html>

home.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Home</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css.css" /> 
</head>
<body>
<LINK REL="SHORTCUT ICON" HREF="favicon.ico">
<link rel="icon" type="image/gif" href="favicon.gif" >
<div class="box">
<div class="header">
<table>
<tr>
<td>
<img src="images2.jpg" width=150px height=80px style="margin-left:5px; margin-top:5px;" alt="NCR Corp."/>
</td>
</tr>
<tr>
</tr>
</table>
</div>
<div class="content" style="height:500px;">
<%@ page language="java" %>
<%@ page import= "java.io.IOException"%>
<%@ page import= "java.lang.String"%>
<%@ page import= "java.text.NumberFormat"%>
<%@ page import= "java.util.Date"%>
<%@ page import= "java.io.*"%>
<%@ page import= "java.net.*"%>
<%@ page import= "java.sql.*" %>
<%@ page import="java.util.List" %>  
<%@ page import="java.util.Iterator" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>  
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>  
<%@ page import="org.apache.commons.fileupload.*"%>  
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.io.File" %>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<center>

<%
try
{
String hello = null;
String aplication=null;
String region=null;
String description=null;
String path1=null;
out.println(request);
path1 = request.getParameter("file1");
aplication = request.getParameter("application");
region = request.getParameter("region");
description = request.getParameter("description");
out.println(aplication +" "+region+" "+description);
Connection con = null;
out.println(aplication +" "+region+" "+description+""+path1);

Class.forName("oracle.jdbc.driver.OracleDriver");

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@abc.com:1521","USER","USER");

Statement stmt = con.createStatement();

int update=0;

boolean isMultipart = ServletFileUpload.isMultipartContent(request); 
        out.println(isMultipart);
     if (!isMultipart)
     {  out.println("hello1");

     } 
     else 
     {  out.println("hello2");

           FileItemFactory factory = new DiskFileItemFactory();  
           ServletFileUpload upload = new ServletFileUpload(factory);  
           List items = null;  
           try
           {  
             items = upload.parseRequest(request);  
           } 
           catch (FileUploadException e)
           {  
               e.printStackTrace();  
           }  
           Iterator itr = items.iterator();  
        while (itr.hasNext()) 
        {  
           FileItem item = (FileItem) itr.next();  
           if (item.isFormField())
           {  
           }
           else 
           {  
                try
                {
                   String itemName = item.getName(); 
                   String path = "C:\\apache-tomcat-6.0.32\\webapps\\infoapp\\uploadedfiles\\"+ itemName;
                   File savedFile = new File(path);  
                   item.write(savedFile);
                   out.println("hello3");

                   update = stmt.executeUpdate("insert into in_details(app_name,region,in_desc,attachment) values('"+aplication+"','"+region+"','"+description+"','"+path+"')");
                 }
               catch (Exception e)
               {  
                  e.printStackTrace();  
               }  

            }
        }
    }

    }
catch(Exception e)
{
out.println("This is an exception" + e);
}
%>
</center>
</div>
<div class="footer">
</div>
</div>
</body>
</html>
View Answers

June 7, 2011 at 1:29 PM

Hi Rashi Goel

Go through the link below:

http://www.roseindia.net/tutorial/java/jdbc/insertclob.html









Related Tutorials/Questions & Answers:
Problem in request Object
Problem in request Object  I have created a form where I have file input along with other inputs. I am using jsp to process the inputs. File input is not processing while the rest of the data is being processed.Please Help me out
Problem in request object
Problem in request object  I have created a form where I have file...=null; String description=null; String path1=null; out.println(request); path1...(); int update=0; boolean isMultipart = ServletFileUpload.isMultipartContent(request
Advertisements
request object value
request object value for whole application. Problem is..envirement session...request object value  Hi Friends I am developing a web application... request value for whole application without using session,application object. Please
Session Object from request
request object? Why are we adding cookie object into response object? Why are we getting cookie object from request object? I know all methods are available its relevant class. is there any reason for getting session object from request
JSP Request Object
JSP Request Object  JSP Request Object ?   request object... an HTTP request. The request object is used to take the value from the client?s... of the object request is http.httpservletrequest. The object request is written
Ajax request object
Ajax request object  i have to open more than one time a same jsp page with same input using Ajax.. But it will be opened only one time. i can open If i give different input.. how to solve this problem ADS_TO_REPLACE_1
request object - JSP-Servlet
request object  What is Difference Between request.getHeader("x-forwarded-for") and request.getServerName() pls give me reply as soon as possible
getQueryString() Method Of The Request Object
getQueryString() Method Of The Request Object... the getQueryString() method of the request object. Here, you will learn more... of the request object is used for getting the query string which is the values
removeAttribute() Method Of The Request Object
removeAttribute() Method Of The Request Object... for the method removeAttribute() of the request object. This method removes... the removeAttribute() method of the request object in JSP by learning through
getAttribute() Method Of The Request Object
getAttribute() Method Of The Request Object... for the illustration of the getAttribute() method of the request object in JSP... that is set through the setAttribute() method of the request object. The getAttribute
Request Object In JSP
Request Object In JSP     ... Request object. This object retrieves values whatever client passes... to the server, is received by the HTTP request object of the JSP. To access
getParameterValues() Method Of The Request Object
getParameterValues() Method Of The Request Object... about the getParameterValues() method of the request object. Here, you will learn... of the request object used for getting the string array containing all
getParameterNames() Method Of The Request Object
Example of getParameterNames() Method Of The Request Object in a JSP page...() method of the request object. You will learn more about the procedure of using the getParameterNames() method of the request object. Why the method used and how
JSP implicit object "request"
. The 'request' object takes the value from the web browser and pass...) getCookies():This method of 'request ' object retrieves all...(); getMethod():The "getMethod()" of request object is used to return
getHeader() Method Of The Request Object
getHeader() Method Of The Request Object  ... illustration about the getHeader() method of the request object. Here, you will learn... retrieved by the method getHeaderNames() of the request object that gives all
getAttributeNames() Method Of The Request Object
getAttributeNames() Method Of The Request Object... GetAttributeNamesMethod1.jsp file that gets the request and response object sent... you the detailed explanation of the getAttributeNames() method of the request
setAttribute() Method Of The Request Object
setAttribute() Method Of The Request Object... the best illustration about the setAttribute() method of the request object in JSP... the request object through the dispatcher method. The set value of the attribute
getRequestURI() Method Of The Request Object
getRequestURI() Method Of The Request Object       This section gives you the detailed explanation of the getRequestURI() method of the request object
Spring MVC, request object in val;idator class
Spring MVC, request object in val;idator class  Spring MVC validators by default gives you a commandClass object which you can validate. For each variable in the commandClass there is a binding on jsp, which populates
how to convert xml string to soap request object using axis1.4?
how to convert xml string to soap request object using axis1.4?  how to convert xml string to soap request object using axis1.4
getParameter() Method Of The Request Object
getParameter() Method Of The Request Object... you about the getParameter() method of the request object. This section provides... by the getParameter() method of the request object. This is the method, used
Request Object In JSP.
Access properties of bean from request object using OGNL.
Access properties of bean from request object using OGNL. In this section, we will introduce you how to access beans properties from request object using...; |Accessing Request |ADS_TO_REPLACE_9 <table cellpadding="2" cellspacing
getParameter() method of request object.
object
object  is it possible to create object in the same class..?.   Yes, you can. class CreateObject { CreateObject(){ System.out.println("I have an object."); } public static void main(String[] args
JSP Request URI
the request object that will return the URI of the current JSP page. Understand...; request.getRequestURI ( ) method, which return the URI of the request object... JSP Request URI   
Request header display in a jsp page
to the server, the request defines an object to provide client request information... information on the page. Request object's getMethod() method returns request method... Request header display in a jsp page  
Access Request and Response
the request and response object in struts 2 application. To access the request... action class. Accessing the request and response object, you need a struts.xml... the setServletRequest() (for setting the request object)  and getServletRequest
object of object class
object of object class  what do u mean by "object of object class
Read MultipartRequest object twice. - JSP-Servlet
for "How to revert back ServletInputStream object after reading once." Q. Now I am facing problem for ServletInputStream object. Can we read stream twice using ServletInputStream object? Can we read MultipartRequest request object
getHeaderNames() Method Of The Request Object
getHeaderNames() Method Of The Request Object       In this section, you... the brief introduction about the getHeaderNames() method of the request object
JSP Response Object
JSP Response Object  JSP response Object ?   The response object denotes the HTTP Response data. The result or the information of a request... of the client. This contrasts with the request object. The class or the interface name
request to help
request to help   how to write the program for the following details... of the employee object with the employee id (auto -increment, assigning 1 to first...() of the employee object to print employee details. User may enter date in any
How to send the request and get the request?
How to send the request and get the request?  how to send a request to a JSP file in another domain in the same server and get the request done i.e how to include JSP file of one domain to another doamin JSP within in the same
problem with package
problem with package  Dear sir, i have created one java file... in " net" folder.The problem is i want to use that .class file in some other project.well i created the object and set the class_path but still it showing error
Object slicing
Object slicing  I have a program as bellow: #include<iostream.h> #include<conio.h> class A { public: int x... of A" Can any one solve this problem
request this program
request this program  if three text box value in my program i want to check the three input boxes values and display greatest two values
Problem in enctype=
Problem in enctype=  im using a page which is in JSP. i have some.... but the problem is the uploaded file is not stored in the prefered folder. i printed... = ServletFileUpload.isMultipartContent(request); if (!isMultipart
object creation
object creation  when will java object is created? is it at runtime or compiletime
Object Oriented
Object Oriented  C++ is Purely object oriented or not .Then why java called purely object oriented
Object reference not set to an instance of an object
Object reference not set to an instance of an object  Object reference not set to an instance of an object
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to [email protected]
Servlet problem
problem from last three month and now i hope rose india developers... connectivity code it works but problem is with servlet page. My servlet code...() { } protected void doGet(HttpServletRequest request, HttpServletResponse response
struts url problem in Switching module using SwitchAction class - Struts
attributes set in request i want to send the ArrayList object...struts url problem in Switching module using SwitchAction class  when i use SwitchAction class,it creates a problem take a examle when i go
Session Object
Session Object  Why do we require Session Object?  Hello.... The session object is used by the developers to store and retrieve user's related data such as login details. The javax.servlet.http.HttpSession object
code problem - Struts
,HttpServletRequest request,HttpServletResponse response) { try... Object[] arr =dao.getList(conn); for(Object i:arr... form,HttpServletRequest request,HttpServletResponse response){ try
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
object as argument
object as argument  what happens when we pass a object into a method???if java is pass by value how does this makes a difference.....pllzzz give me more clarification on why we pass objects in a margument
ArrayList object
ArrayList object  i have am ArrayList object it containg data base records in it, now i want to display this ArrayList object data in my jsp programe, plz help me
how to get session object in simple java class??
how to get session object in simple java class??  i am fallowing a simple mvc architecture. actually my problem is.... i am using 4 classes in my... the value to GroupPojo.java and set this pojo object into session. sending control

Ads