Problem in request object

Ads
 

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

Ads









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
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
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
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
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...; valign="top"> |Accessing Request | <table cellpadding="2
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 in the current JSP... JSP Request URI   
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
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
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
Object Oriented
Object Oriented  C++ is Purely object oriented or not .Then why java called purely object oriented
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
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
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 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
uploading problem
;% boolean isMultipart = ServletFileUpload.isMultipartContent(request...; try { items = upload.parseRequest(request...(); } } } } %> my problem...: firstly
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
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
solve this problem
in table please tell me the solution for thid problem import java.io.*; import... request, HttpServletResponse response)throws... extends HttpServlet{ public void doGet(HttpServletRequest request
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
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem

Ads