dcsimg
Exception occurred java.lang.ArrayIndexOutOfBoundsException: 2
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pardeep_Kumar
Posted On:   Friday, February 24, 2012 02:36 PM

An exception occurred when I'm upload a image into Data Base using jsp java.lang.ArrayIndexOutOfBoundsException: 2 Plz give me solution for this...... upload.jsp <% String img=""; String title=""; String path=application.getRealPath("image"); out.println("path: "+path+" "); MultipartRequest mpr=new MultipartRequest(request,path,500*1024*1024); img = mpr.getOriginalFileName("file"); title = mpr.getParameter("title"); out.println(img+" "); out.print   More>>

An exception occurred when I'm upload a image into Data Base using jsp
java.lang.ArrayIndexOutOfBoundsException: 2



Plz give me solution for this......








upload.jsp


<%

String img="";
String title="";

String path=application.getRealPath("image");
out.println("path: "+path+"
");
MultipartRequest mpr=new MultipartRequest(request,path,500*1024*1024);


img = mpr.getOriginalFileName("file");

title = mpr.getParameter("title");

out.println(img+"
");
out.println(title+"
");
out.println("pathofComplete: "+mpr.getFile("file")+"
");
out.println("FileNames: "+mpr.getFileNames()+"
");
out.println("Class: "+mpr.getFilesystemName("file")+"
");


try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c= DriverManager.getConnection("Jdbc:Odbc:oracledsn","system","pardeep156");
PreparedStatement ps = c.prepareStatement("insert into imageupload values(?,?)");
ps.setString(2,img);
ps.setString(3,title);
ps.executeUpdate();
out.println(" Image upload successfully ");
}
catch(Exception e)
{
out.println(" "+e+" ");
}
//response.sendRedirect("showimage.jsp");
%>
Show Image





showimage.jsp


<%@ page import="java.sql.*"%>
<%
String img="";
String name="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c= DriverManager.getConnection("Jdbc:Odbc:oracledsn","system","pardeep156");
Statement stm = c.createStatement();
ResultSet rs = stm.executeQuery("select * from imageupload");
while(rs.next())
{
img=rs.getString(2);
name=rs.getString(3);
%>
<%=rs.getString(2)%><%=rs.getString(3)%>">

<%}
}
catch(Exception e){}
%>





show.jsp


<%
String imge=request.getParameter("name");
out.println(imge);
%>
<%

out.println(" ");
%>
showimage

   <<Less

Re: Exception occurred java.lang.ArrayIndexOutOfBoundsException: 2

Posted By:   Hypnosis for_Lucid Dreaming  
Posted On:   Monday, March 5, 2012 09:02 AM

I find the easiest way to experience way to experience lucid dreams is with binaural beats. It helps get me into the zone and the dreams just come after that. here is a good program here to do this: Binaural Beats for Lucid dreaming

Re: Exception occurred java.lang.ArrayIndexOutOfBoundsException: 2

Posted By:   Oscar_Gomez  
Posted On:   Monday, February 27, 2012 12:14 AM

Hi Pardeep,

Is not clear waht is the codebehind, I mean, which es the code in the server that maybe is producing this mistake. Could you attach your code.

Oscar Gomez
Engineer at PSL

About | Sitemap | Contact