Hi, Iam facing with one problem.Iam uploading file from swing Interface through servlet.Now when I select above 4mb size of file then it giving me error On Dos-prompt.My servlet working perfectly with html form with any size of file coz in my servlet I can set the accept size of file.plz guide me how I can slove the problem.Below r codes:- ImageIcon Upload=new ImageIcon("images/Upload.gif"); Button=new JButton(Upload); Button.setToolTipText("Upload");
Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int returnVal = fc.showOpenDialog(ActionDemo4.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String aa=file.getAbsolutePath(); textArea3.append(aa); textArea2.append("Local URL:"); long l=file.length(); try { byte buff[]=new byte[(int)file.length()]; InputStream fileIn=new FileInputStream(aa); int i=fileIn.read(buff); String conffile=new String(buff);
String str1=textArea10.getText();
url = new URL ("http://127.0.0.1:7001/FileUpload?x="+str1);
printout = new DataOutputStream (urlConn.getOutputStream ()); String preContent = "-----------------------------7d01ecf406a6\r\nContent-Disposition: form-data;name=\"upload\"; filename=\""+aa+"\"\r\nContent-Type:application/octet-stream\r\n\r\n"; String postContent = "\r\n-----------------------------7d01ecf406a6--\r\n"; printout.writeBytes(preContent); printout.writeBytes(conffile); printout.writeBytes(postContent); printout.flush (); printout.close (); Top most Error's r like that:- ----------------------------- C:\jdk1.2.2\bin>java ActionDemo4 Exception occurred during event dispatching: java.lang.OutOfMemoryError at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java, Compiled Code) at java.io.DataOutputStream.writeBytes(DataOutputStream.java:263) Thanks for ur valuable time Bikash
------------------
Bikash Paul
Ranch Hand
Joined: Dec 04, 2001
Posts: 340
posted
0
Hi, Plz help me. Regards Bikash ------------------
Bikash Paul
Ranch Hand
Joined: Dec 04, 2001
Posts: 340
posted
0
Hi, Plz help me. Regards Bikash ------------------
Daniel Brugger
Greenhorn
Joined: Dec 13, 2001
Posts: 5
posted
0
hi ever played with the memory options of the JVM? for the java command in jdk 1.1.x they were: -mxNNm (to set heap size to NN MB) -msNNm (to set stack size to NN MB) for java2, i'm not sure but i think they changed - have a look at the manpages! hth Daniel