Extension type for mime-type "multipart/form-data"
Hello:
If I want to register a mime-type of type "multipart/form-data" in WebLogic 6.0
what, if any, extension should I specify fot it in the web.xml? Is it necessary
to specify this mime-type for handling "multipart/form-data" type http requests?
Thanks
John
You cannot use request.getParameter() for Multipart/form-data.
You need to Use getInputStream and use the InputStream to read data.
Please Refer Jeason Hunters Implementation for the same. Its a very good example.
Kumar.
John Buckley wrote:
> Hmm. Strange. When I send in a multipart/form-data request and when I try to do
> a request.getParameter within my servlet it returns null and also throws a socket
> exception at the server console.
>
> Any ideas?
>
> John
>
> Mettu Kumar <[email protected]> wrote:
> >I don't think its neccesary as I am able to run my code with wls6.0 without
> >registering
> >multipart/form-data.
> >
> >kumar.
> >John Buckley wrote:
> >
> >> Hello:
> >> If I want to register a mime-type of type "multipart/form-data" in
> >WebLogic 6.0
> >> what, if any, extension should I specify fot it in the web.xml? Is
> >it necessary
> >> to specify this mime-type for handling "multipart/form-data" type http
> >requests?
> >>
> >> Thanks
> >>
> >> John
> >
Similar Messages
-
ALSB 2.5 - routing request containing multipart/form-data
Hello,
I'm having difficulty routing a request (multipart/data-form with 2 MIME sections) in a
business service.
First, I set up the "attachments" variables in a stage:
<ctx:attachments>
<ctx:attachment>
<ctx:Content-Disposition>form-data; name="RI"; filename="RI"</ctx:Content-Disposition>
<ctx:Content-Type>text/plain</ctx:Content-Type>
<ctx:Content-ID>1146702408781_1</ctx:Content-ID>
<ctx:body>
<RI/>
</ctx:body>
</ctx:attachment>
<ctx:attachment>
<ctx:Content-Disposition>form-data; name="CI"; filename="CI"</ctx:Content-Disposition>
<ctx:Content-Type>text/plain</ctx:Content-Type>
<ctx:Content-ID>1146702408781_1</ctx:Content-ID>
<ctx:body>
<CI/>
</ctx:body>
</ctx:attachment>
</ctx:attachments>
then do node replacements of <RI/> and <CI/> in each
<ctx:body> section.
Then in the routing node,
"Set Transport Headers" for "Outbound Request"
[x] Pass all Headers through Pipeline
Add Header
[Content-Type] --> [Set Header to "multipart/form-data"]
Then I used Ethereal (network protocol analyzer) to
observe the raw packets that business service sent
the request to the target service. It looked like
the POST httprequest output by ALSB does not conform to
the other posting programs that I have wrote in Python
and Ruby. The target webservice rejects the request
sent by ALSB, but accepts those sent by the Python/Ruby
programs.
Anyone here have any experience in how to set this up?
Thanks
CharlesHello,
Make sure you construct the attachment variable properly as specified in the documentation:
http://e-docs.bea.com/alsb/docs26/userguide/context.html#wp1052039
Gregory Haardt
ALSB Prg. Manager
[email protected] -
Hi There,
I am new to FLEX and also new to writing a client for a web service.
My question is more about flex (Flash builder 4.5) APIs, what APIs to use.
I want to access a web service, that's published here.
https://build.phonegap.com/docs/write_api
here is the description of webservice
===========
1) I have to do a post on POST https://build.phonegap.com/api/v1/apps
2) content type has to be "multipart/form-data"
3) JSON bodies of requests are expected to have the name 'data'
data will be someting like this
'data={"title":"API V1 App","package":"com.alunny.apiv1","version":"0.1.0","create_method":"file"}'
4) include a zip file in the multipart body of your post, with the parameter name 'file'.
===========
I want to make a 'multipart/form-data' Post and send
one string and one zip file.
My first question to self was If i send both string + binary data in the body ...
how will server understand where string end and where zip file starts?
Then read on W3.org( http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2 )
How is text + binary data can be sent through "multipart/form-data" post requst.
there has to be some boundries.
After this I read and example in flex and tried following it.
http://codeio.wordpress.com/2010/04/03/5-minutes-on-adobe-flex-mimic-file-upload-for-in-me mory-contents/
but it doesn't seems to be working for me.
public function createNewApp(cb:Function , appFile : File):void
var service:HTTPService = new HTTPService();
service.url = ROOT+"apps";
service.showBusyCursor = true;
service.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void {
//translate JSON
trace(e.result);
var result:String = e.result.toString();
var data:Object = JSON.parse(result);
cb(data.link);
service.addEventListener(FaultEvent.FAULT, defaultFaultHandler); //todo : allow user to add his own as well
authAndUploadNewApp(service,appFile);
private function authAndUploadNewApp(service:HTTPService,appFile : File):void {
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode(username + ":"+password);
service.headers = {Accept:"application/json", Authorization:"Basic " + encoder.toString()};
service.method ="POST";
var boundary:String = UIDUtil.createUID();
service.contentType = "multipart/form-data; boundary=—————————" + boundary;
var stream:FileStream = new FileStream();
stream.open(appFile, FileMode.READ);
var binaryData:ByteArray = new ByteArray();
var fileData : String = new String();
stream.readBytes(binaryData);
stream.close();
fileData = binaryData.readUTFBytes(binaryData.bytesAvailable); // I think this is where I have problem.... how do
//how do i converrt this bytearray/stream of data to string and send it in my post request's body - i guess if this step work rest should work..
var params: String = new String();
var content:String = "—————————" + boundary + "nr";
content += 'Content-Disposition: form-data; name="data";' + '{"title":"ELS test app 2","package":"com.elsapp.captivate","version":"12.3.09","create_method":"file"}' + "nr";
content += "—————————" + boundary + "nr";
content += 'Content-Disposition: form-data; name="file";' + fileData + "nr";
content += "—————————–" + boundary + "–nr";
service.request = content;
service.send();In the past I have used URLVariables with URLRequest and URLLoader to achieve this kind of requirement.
Check out http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_3 .html which should be useful. My preference has always been to use this style instead of HTTPService objects, giving you a little more control which is what you need here.
Let me know if you need any more assistance. -
No object DCH for MIME type multipart/related
Hi, everyone!!!
When I execute my code, I got this exception:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/related
boundary="----=_Part_0_20851530.1186777547859"
the funny things is : I got it work before. However, when I come back a few days to run, it doesn't.
I use tomcat 5.0,
mail.jar: version: 1.6
activation.jar:version: I don't know but I download the new ones in sun website.
Note: Also, when I run the code below in standalone application (java application), it works but doesn't work on tomcat application
Any help would be appreciate.
I tried some helps tips from other website such as http://www.jguru.com/faq/view.jsp?EID=237257
and still doesn't work :((((
***********Here is my code**********
********props is properties file...............
Authenticator auth = new SMTPAuthenticator();
// Get session
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(true);
// Create the message
Message message = new MimeMessage(session);
// Fill its headers
message.setSubject(subject);
message.setFrom(new InternetAddress(from));
for(int x=0;x<recipients.size();x++)
message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipients.get(x).toString()));
// Create your new message part
BodyPart messBodyPart=new MimeBodyPart();
// Set the HTML content, be sure it references the attachment
String htmlText="<h1>Hi</h1>"+"<img src=\"cid:picture\">";
// Set the content of the body part
messBodyPart.setContent(htmlText, "text/html");
// Create a related multi-part to combine the parts
MimeMultipart multipart=new MimeMultipart("related");
// Add body part to multipart
multipart.addBodyPart(messBodyPart);
// Create part for the image
messBodyPart=new MimeBodyPart();
// Fetch the image and associate to part
System.out.println("before dataSource");
DataSource fds=new FileDataSource(this.getString("image_location"));
System.out.println("After dataSource");
messBodyPart.setDataHandler(new DataHandler(fds));
System.out.println("*************** dataSource");
// Add a header to connect to the HTML
messBodyPart.setHeader("Content-ID", "<picture>");
// Add part to multi-part
multipart.addBodyPart(messBodyPart);
// Associate multi-part with message
message.setContent(multipart);
// Send message
System.out.println("Before Send");
Transport.send(message);
System.out.println("Finish");
}Thank you for your response!!!
I already found the solution. For those who still having problem send e-mail, make sure to put mail.jar and activation.jar in the same location.
Also, make sure to check catalina.xml to make sure those jars are same location!!!->That what I found out.
->I put jars in same location of my eclipse project but it turns out, the tomcat app server didn't put them in same location.
Anyway, Thank you java_2006 for your response!!!!!
:) -
Javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
hi there
i'm new to javamail and i'm trying to build a sample tool able only to send an e-mail.
i'm connecting to my office mail-server (web-mail). I'm sending from my office's address to an hotmail's address but i always receive the UnsupportedDataTypeException message. The same problem occurs if i mail to another user of web-mail
Have someone already encountered this problem?
Thanks in advance
here is my debug:
DEBUG: setDebug: JavaMail version 1.3.2
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "212.239.51.130", port 25, isSSL false
220 mail.euchia.it ESMTP
DEBUG SMTP: connected to host "212.239.51.130", port: 25
EHLO tim1
250-mail.euchia.it talking to [192.168.1.145] ([192.168.1.145])
250-ENHANCEDSTATUSCODES
250-SIZE
250-ETRN
250-ATRN
250-DSN
250-8BITMIME
250 HELP
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "SIZE", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "ATRN", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "HELP", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
250 2.1.0 <[email protected]>... Sender ok
RCPT TO:<[email protected]>
250 2.1.5 <[email protected]>... Recipient ok; will forward
DEBUG SMTP: Verified Addresses
DEBUG SMTP: [email protected]
DATA
354 Enter mail, end with "." on a line by itself
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_0_597230.1126769454656"
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:851)
at javax.activation.DataHandler.writeTo(DataHandler.java:305)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1206)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1611)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:526)
at javax.mail.Transport.send0(Transport.java:151)
at javax.mail.Transport.send(Transport.java:80)
at msgmultisendsample.main(msgmultisendsample.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)I hope this will help you.
http://jce.iaik.tugraz.at/products/03_cms/faq/index.php
Thanks,
Amol -
Dear SharePoint Developers,
Please help.
I need to know How to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx?
I think this is a "sealed column", whatever that is, which is shown in SPD 2013 as a column of content type "document, folder, MyCustomContentType".
I know when I set the column order in my custom Content Type settings page, it is correct.
But, when I load the NewDocSet.aspx page, the column order that I set in the settings page is NOT used for this "sealed column" which is bad.
Can you help?
Please advise.
Thanks.
Mark Kamoski
-- Mark KamoskiHi,
According to your post, my understanding is that you want to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx.
Per my knowledge, if you have Content Type management enabled for the list or library (if you see a list of content type with the option to add more), the display order of columns is set for each content type.
Drill down into one of them and you'll see the option under the list of columns for that content type.
To apply the column order in the NewDocSet.aspx page, you need to:
Select Site Settings, under Site Collection Administration, click Content type publishing. In the Refresh All Published
Content Types section, choose Refresh all published content types on next
update.
Run two timer jobs(Content Type Hub, Content Type Subscriber) in central admin(Central Administration--> Monitoring--> Review timer jobs).
More information:
http://sharepoint.stackexchange.com/questions/95028/content-types-not-refreshing-on-sp-online
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Problem with ENCTYPE='multipart/form-data'
In my program I want to upload a file along with other details.
I've dowloaded org.apache.commons.fileupload.* jar files and everything works fine only if I give
<INPUT TYPE='file' NAME='file1'>
i.e the file is uploaded
But if I add any other field it becomes blank
Title : <INPUT id=text1 maxlength="30" name=GHN1 >
the value of GHN1 becomes blank. what cud be the problem.
Here is my program
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,java.text.SimpleDateFormat.*,java.text.ParseException.*,java.text.*,java.text.DateFormat.*,java.util.*,java.util.Date.*,com.gh.db.*,org.apache.commons.fileupload.*,org.apache.commons.fileupload.servlet.ServletFileUpload,org.apache.commons.fileupload.disk.DiskFileItemFactory,org.apache.commons.io.FilenameUtils,java.io.*,java.io.File,java.lang.Exception" errorPage="Error.jsp" %>
<%
String TACm1="";
String TASid,Nme="",Cm2="",GHN1="",GHN2="",GHN3="",Sid="";
TACm1=((request.getParameter("TAIdCombo"))!=null?(request.getParameter("TAIdCombo")):"");
DBconnection TApool = DBconnection.getInstance();
Connection con2 = TApool.getConnection();
con2.setAutoCommit(false);
Statement TAst1 = con2.createStatement();
ResultSet TArs1 = null,rs2=null,rs1=null;
Cm2=((request.getParameter("TMIdCombo2"))!=null?(request.getParameter("TMIdCombo2")):"");
java.util.Date d1;
java.sql.Date d2;
SimpleDateFormat format=new SimpleDateFormat("dd/MM/yyyy");
%>
<html>
<head>
<TITLE>Guest Houses of DOS</TITLE>
</head>
<%@ include file="StdValidations.js" %>
<%@ page buffer="1094kb"%>
<script Language="JavaScript">
</script>
<body onload="window.history.forward(1);">
<FORM ENCTYPE='multipart/form-data' name="GHInfoDetails1"
method='POST' action="GHInfoDetails1.jsp">'<br><br><br>
<center>
<%
String LoginName= "";
String Name= "";
String SectionName= "";
try
LoginName = session.getAttribute("LoginName").toString();
Name = session.getAttribute("Name").toString();
SectionName = session.getAttribute("SectionName").toString();
catch(NullPointerException npe)
%>
<jsp:forward page="LoginHere.jsp" >
<jsp:param name="SessionMode" value="Session Expired try again to log on" />
</jsp:forward>
<%
%>
<%
GHN1 = request.getParameter("GHN1");
if (GHN1 == null) GHN1 = "";
GHN2 = request.getParameter("GHN2");
if (GHN2 == null) GHN2 = "";
GHN3 = request.getParameter("GHN3");
if (GHN3 == null) GHN3 = "";
%>
<table width="100%" bgcolor="#F7EDF7">
<tr >
<td align="center">
<img src="Images/Title2.gif">
</td>
</tr>
</table>
<table width="100%" bgcolor="#F7EDF7">
<tr>
<td >
<b><font face="Times New Roman, Times, serif" color="#402180" size="+1">Logged in as: <%= Name %></font></b>
</td>
<td >
<b><font face="Comic Sans MS" color="#402180" size="+1">Other Details of Guest House</font></b>
</td>
<td align="right">
<b><font face="Times New Roman, Times, serif" color="#402180" size="+1">Logout</font></b>
</td>
</tr>
</table>
<table width="100%" bgcolor="#B6C7E5" border="1">
<tr>
<td valign="top">
</br>
<p><img src="Images/bullet.gif"><b><font face="Times New Roman, Times, serif" color="#402180" size="+0">Defining Guest House Information</font></b></p>
<p><img src="Images/bullet.gif"><b><font face="Times New Roman, Times, serif" color="#402180" size="+0">Cancelling Guest House Information</font></b></p>
</td>
<td align="left"></br>
<table width="100%" bgcolor="#B6C7E5">
<tr>
<td width="60%" align="right"></br>
<P >Category : <select onChange="TAMAssignCombo2();" name="TMIdCombo2" style="WIDTH: 120px" >
<option value="-">Select</option>
<% try
PreparedStatement ps6=con2.prepareStatement("Select CategoryName from TableCategory order by CategoryName");
rs2 = ps6.executeQuery();
while(rs2.next())
Sid=rs2.getString(1);
%>
<option value = "<% out.write(Sid); %>"><% out.write(Sid); %></option>
<%
catch(Exception e)
e.printStackTrace();
%>
<Script>alert("Exception Occured : <%= e %>");</Script>
<%
%>
</select>
</P>
</td>
</tr>
<tr align="center">
<td>
Title : <INPUT id=text1 maxlength="30" name=GHN1 onKeyPress="if (((event.keyCode > 32) && (event.keyCode < 48)) || ((event.keyCode > 57) && (event.keyCode < 65)) || ((event.keyCode > 90) && (event.keyCode < 97))) event.returnValue=false;">
</td>
</tr>
<tr align="center">
<td>
Reference No : <INPUT id=text1 maxlength="100" name=GHN2 onKeyPress="if (((event.keyCode > 32) && (event.keyCode < 48)) || ((event.keyCode > 57) && (event.keyCode < 65)) || ((event.keyCode > 90) && (event.keyCode < 97))) event.returnValue=false;">
</td>
</tr>
<tr align="center">
<td>
Date : <INPUT id=text1 maxlength="30" name=GHN3 >
</td>
</tr>
<tr align="center">
<td >
</br>
File Name: <INPUT TYPE='file' NAME='file1'></p>
</td></tr>
<tr>
<td align="center">
<INPUT TYPE='submit' VALUE='Submit' ></br>
<b><font face="Times New Roman, Times, serif" color="#402180" size="3">(Information like distance,direction from central places such as Railway station, Airport, Bus Terminal....etc can be added in a file of windows format(such as word, pdf...) and can be uploaded through this screen. This will be displayed for the ISRO Guests.</font></b>)
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" bgcolor="#B6C7E5">
<tr>
<td align="center">
</br>
<img src="Images/Home.jpg">
</td>
</tr>
</table>
<% if (ServletFileUpload.isMultipartContent(request))
GHN1 = request.getParameter("GHN1");
if (GHN1 == null) GHN1 = "";
GHN2 = request.getParameter("GHN2");
if (GHN2 == null) GHN2 = "";
GHN3 = request.getParameter("GHN3");
if (GHN3 == null) GHN3 = "";
DiskFileUpload fileUpload = new DiskFileUpload();
List list = null;
try
list = fileUpload.parseRequest(request);
catch(FileUploadException ex)
throw new ServletException("Wrapped",ex);
Iterator iter = list.iterator();
while (iter.hasNext())
FileItem item = (FileItem) iter.next();
if (!item.isFormField())
File itemFile = new File(item.getName());
Nme=itemFile.getName();
%>
<%
File destDir = new File(getServletContext().getRealPath("/")
+"stored");
if(!destDir.exists())
destDir.mkdirs();
File destFile = new File(getServletContext().getRealPath("/")
+"stored"+File.separator+itemFile.getName());
try
item.write(destFile);
catch(Exception ex)
//throw new ServletException("Wrapped",ex);
TACm1=SectionName;
%><script>alert("<%=GHN1%>");</script><%
try
PreparedStatement ps26= con2.prepareStatement("select CategoryNo from TableCategory where CategoryName=?");
ps26.setString(1,Cm2);
rs1=ps26.executeQuery();
while (rs1.next())
PreparedStatement ps16=con2.prepareStatement("inset into TableMetaData (CategoryNo,Title,RefernceNo,Date,FileName) values(?,?,?,?,?)");
ps16.setString(1,rs1.getString(1));
ps16.setString(2,GHN1);
ps16.setString(3,GHN2);
d1=format.parse(GHN3);
d2=new java.sql.Date(d1.getTime());
ps16.setDate(4,d2);
ps16.setString(5,Nme);
int NoOfRows=ps16.executeUpdate();
con2.commit();
catch(Exception e)
e.printStackTrace();
%>
<script> alert("Error : <%= e %>"); </script>
<%
%>
<%
if (TAst1 != null) TAst1.close();
if (con2 != null)
con2.rollback();
con2.setAutoCommit(true);
TApool.returnConnection(con2);
%>
<input name="HomePage" type="hidden">
</form>
</body>
</html>This article is worth reading: http://balusc.blogspot.com/2007/11/multipartfilter.html
-
Problem with transfering unicode form data in MULTIPART/FORM-DATA
HI experts,
I have this web based multilingual application. Page 1(form6.jsp) is basic registeration form with 5 fields and one image upload to the server. Page 2(verify.jsp) is another jsp page for verification of UTF data entered in page 1.
page 2 (verify.jsp) also uses a bean called (verify.java) for picking up values. page 3(insertEntry.jsp) is the page for inserting that data into the Database and uses a bean called (logicbean.java).
Now, the problem im facing here is that if i use multipart/form-data, the unicode text filled in page1 is shown as garbage when its is transfered to page2 and displayed on page2. It is all gibberish. But if i do not use multipart/form-data, the unicode text transfered from page1 to page2 is displayed perfectly on page2.Im using devenagari(UTF) language for filling in details.
// form6.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.*,java.text.*" %>
<%@ page import="com.oreilly.servlet.*" %>
<%
request.setCharacterEncoding("UTF-8");
%>
<HTML>
<HEAD>
<TITLE>
<%=session.getValue("main.title")%>
</TITLE>
</HEAD>
<h1><center><%=session.getValue("main.head")%><Center>
<BODY background="brown.bmp">
<form name=form6 action="verify.jsp" method="post" enctype="multipart/form-data">
<center>
<font>
<table border=1>
<tr>
<td colspan=2><center><img src="asok.bmp"></center>
</tr>
<tr>
<td >
<b>1.)<%=session.getValue("main.ec")%></b>
</td>
<td></td>
</tr>
<tr>
<td align="right"><b><%=session.getValue("main.ecname")%></b>                 <input type="text" name="votername"></td>
<td></td>
</tr>
<tr>
<td align="right"> <b><%=session.getValue("main.ecsurname")%></b>            <input type="text" name="votersurname"></td>
<td></td>
</tr>
<tr>
<td align="left"><b>2.)<%=session.getValue("main.rel")%></b>                
<select name="relation" onchange="if(this.selectedIndex!=0){this.form.texthiddenrelation.value=this.options[this.selectedIndex].value}" size="1">
<option>Choose</option>
<option value="father">Father</option>
<option value="mother">Mother</option>
<option value="husband">Husband</option>
</select>
<input type="hidden" name="texthiddenrelation" />
</td>
</tr>
<tr>
<td align="right"><b><%=session.getValue("main.relname")%></b>                 <input type="text" name="parentname">
<td></td>
</tr>
<tr>
<td align="right"><b><%=session.getValue("main.relsurname")%>            </b><input type="text" name="parentsurname">
<td></td>
</tr>
<tr>
<td align="right"><b>3.)<%=session.getValue("main.sex")%></b>                                                 
      
<select name="sex" onchange="if(this.selectedIndex!=0){this.form.texthiddensex.value=this.options[this.selectedIndex].value}" size="1">
<option>Choose</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
<input type="hidden" name="texthiddensex" /> </td>
<td align="right"><b><%=session.getValue("form6.image")%><input type ="file" name=pic1 onchange={this.form.pic.value=this.form.pic1.value}><input type= hidden name=pic> </b></td>
</tr>
<tr>
<td colspan=2><b>4.)<%=session.getValue("main.age")%></b><input type="text" name="age">
</td>
</tr>
<tr>
<td><b>5.)<%=session.getValue("main.dob")%></b>
<td><b><%=session.getValue("main.dobday")%></b> <select name="cmbday">
<option value="1"> 1 </option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">10</option>
<option value="10">11</option>
<option value="11">12</option>
<option value="12">13</option>
<option value="13">14</option>
<option value="14">15</option>
<option value="15">16</option>
<option value="16">17</option>
<option value="17">18</option>
<option value="18">19</option>
<option value="19">20</option>
<option value="20">21</option>
<option value="21">22</option>
<option value="22">23</option>
<option value="23">24</option>
<option value="24">25</option>
<option value="25">26</option>
<option value="26">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<b><%=session.getValue("main.dobmonth")%></b><select name="cmbmonth">
<option value="jan">JAN</option>
<option value="feb">FEB</option>
<option value="mar">MAR</option>
<option value="apr">APR</option>
<option value="may">MAY</option>
<option value="jun">JUN</option>
<option value="jul">JUL</option>
<option value="aug">AUG</option>
<option value="sep">SEPT</option>
<option value="oct">OCT</option>
<option value="nov">NOV</option>
<option value="dec">DEC</option>
</select>
<b><%=session.getValue("main.dobyear")%></b> <select name="cmbyear" onchange="if(this.form.cmbday.selectedIndex!=0 && this.form.cmbmonth.selectedIndex!=0 && this.form.cmbyear.selectedIndex!=0){this.form.mergedage.value=this.form.cmbday.options[this.form.cmbday.selectedIndex].value +' '+this.form.cmbmonth.options[this.form.cmbmonth.selectedIndex].text +' '+ this.form.cmbyear.options[this.form.cmbmonth.selectedIndex].value}" size="1">
<option value="1970">1970</option>
<option value="1971">1971</option>
<option value="1972">1972</option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option>
</select>
<input type="hidden" name="mergedage">
</tr>
<tr>
<td colspan=2><b>6.)<%=session.getValue("main.add")%></b>
</tr>
<tr>
<td align="right"><b><%=session.getValue("main.addline1")%></b>                 <input type="text" name="address1" value=""></td>
<td><b><%=session.getValue("main.addstate")%></b>             <input type="text" name="state"></td>
</tr>
<tr>
<td align="right"><b><%=session.getValue("main.addline2")%></b>                 <input type="text" name="address2" onChange="this.form.finaladdress.value=this.form.address1.value + ';' + this.value;"> <input type="hidden" name="finaladdress"> </td>
<td><b><%=session.getValue("main.addcity")%>               </b><input type="text" name="city"></td>
</tr>
<tr>
<td align="right"> <b><%=session.getValue("main.addpin")%></b>              <input type="text" name="pincode">
<td></td>
</tr>
<tr>
<td ><b>7.)<%=session.getValue("main.const")%></b> <input type="text" name="constituency">
<td ><b>8.)<%=session.getValue("main.id")%></b>   <input type="text" name="refno">
</tr>
<tr>
<td colspan="2"><center><input type="reset" name="reset" value="<%=session.getValue("button.reset")%>">  <input type=submit name=Submit value="<%=session.getValue("button.submit")%>"></center></td>
</tr>
<tr>
<td>
</td>
</tr>
</form>
</font>
</BODY>
</HTML>
// verify.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:useBean id="verify" class="pack.verify" scope="request"/>
<%@ page import="com.oreilly.servlet.*" %>
<%@ page import="java.util.*,java.text.*" %>
<%!
MultipartRequest mp;
// ParameterParser pp;
%>
<!-- Perform the actions on the bean. -->
<%
//pp.setCharacterEncoding("utf-8");
%>
<%
try
mp = new MultipartRequest(request, "d:/Files");
out.println("DONE");
/* Set the request object.*/
/* The request object is implicitly available in the JSP page.*/
verify.setRequest(mp);
/* Insert the employee data into the database.*/
verify.verifyEntry();
//verify.setscope();
/* Run the query to retrieve the employee data from the database.*/
//logicbean.runQuery();
catch (Exception e)
System.out.println(e.getMessage());
%>
<HTML>
<HEAD>
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>
</TITLE>
</HEAD>
<BODY background="brown.bmp">
<form name=form6 action="insertEntry.jsp" method="POST">
<center>
<table border=3>
<tr>
<td colspan=2><center><img src="asok.bmp"></center>
</tr>
<tr>
<td >
<b>1.)<%=session.getValue("main.ec")%></b>
</td>
<td rowspan=3>
<image src="<%=verify.getpic()%>" width="85" hieght="85">
</td>
</tr>
<tr>
<td >             <b><%=session.getValue("main.ecname")%></b> <%=verify.getvotername()%>  <input type="hidden" value= "<%=verify.getvotername()%>" name="votername"></td>
</tr>
<tr >
<td>             <b><%=session.getValue("main.ecsurname")%></b><%=verify.getvotersurname()%>
<input type="hidden" value= "<%=verify.getvotersurname()%>" name="votersurname"></td>
</tr>
<tr>
<td ><b>2.)<%=session.getValue("main.rel")%></b><input type="hidden" value= "<%=verify.getvoterrelation()%>" name="texthiddenrelation"></td>
<td><%=verify.getvoterrelation()%></td>
</tr>
<tr>
<td >            <b><%=session.getValue("main.relname")%></b>    <input type="hidden" value= "<%=verify.getparentname()%>" name="parentname"></td>
<td><%=verify.getparentname()%></td>
</tr>
<tr>
<td >            <b><%=session.getValue("main.relsurname")%></b><input type="hidden" value= "<%=verify.getparentsurname()%>" name="parentsurname"></td>
<td><%=verify.getparentsurname()%></td>
</tr>
<tr>
<td><b>3.)<%=session.getValue("main.sex")%></b><input type="hidden" value= "<%=verify.getsex()%>" name="texthiddensex"></td>
<td><%=verify.getsex()%></td>
</tr>
<tr>
<td ><b>4.)<%=session.getValue("main.age")%></B><input type="hidden" value= "<%=verify.getage()%>" name="age"></td>
<td><%=verify.getage()%></td>
</tr>
<tr>
<td><b>5.)<%=session.getValue("main.dob")%></b> <input type="hidden" value= "<%=verify.getdob()%>" name="mergedage"></td>
<td> <%=verify.getdob()%></td>
</tr>
<tr>
<td colspan=2><b>
6.)<b><%=session.getValue("main.add")%></b></td>
</tr>
<tr>
<td>             <b><%=session.getValue("verify.add")%></b><input type="hidden" value= "<%=verify.getadderess()%>" name="finaladdress"> </td>
<td><%=verify.getadderess()%></td>
</tr>
<tr>
<td >            <b><%=session.getValue("main.addpin")%></b><input type="hidden" value= "<%=verify.getpin()%>" name="pincode"></td>
<td><%=verify.getpin()%></td>
</tr>
<tr>
<td>            <b><%=session.getValue("main.addstate")%></b><input type="hidden" value= "<%=verify.getstate()%>" name="state"></td>
<td><%=verify.getstate()%></td>
</tr>
<tr>
<td><b>            <%=session.getValue("main.addcity")%></b><input type="hidden" value= "<%=verify.getcity()%>" name="city"></td>
<td><%=verify.getcity()%></td>
</tr>
<tr>
<td><b>7.)<%=session.getValue("main.const")%></b> <input type="hidden" value= "<%=verify.getconst()%>" name="constituency"></td>
<td><%=verify.getconst()%></td>
</tr>
<tr>
<td><b>8.)<%=session.getValue("main.id")%></b> <input type="hidden" value= "<%=verify.getrefno()%>" name="refno"></td>
<td><%=verify.getrefno()%></td>
</tr>
<tr>
<td colspan="2"><center><INPUT TYPE="button" VALUE="<%=session.getValue("ie.back")%>" onClick="history.go(-1)">
<input type=submit name=Submit value="<%=session.getValue("button.submit")%>"></center><input type="hidden" value= "<%=verify.getpic()%>" name="pic"></td>
</tr>
</form>
</BODY>
</HTML>
//verify.java
package pack;
import java.lang.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.oreilly.servlet.*;
import com.oreilly.servlet.ParameterParser.*;
* @author Administrator
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
public class verify {
String votername = "";
String votersurname = "";
String texthiddenrelation="";
String parentname = "";
String parentsurname = "";
String gender = "";
String texthiddensex="";
String age = "";
String dob = "";
String mergedage="";
String address = "";
String finaladdress="";
String pincode = "";
String state = "";
String city = "";
String constituency = "";
String refno = "";
MultipartRequest request = null;
Connection dbConn = null;
ParameterParser pp;
private String voternameParam;
* Set the request object. This is used for getting parameters.
public void setRequest(MultipartRequest request)
this.request = request;
public void verifyEntry()
throws Exception
/* Connect to the database.*/
//pp.setCharacterEncoding("utf-8");
//String nameParam = request.getParameter("name");
MultipartRequest mp;
System.out.println("connected to db2 through insertemployee");
/* Get all the parameters from the calling HTML form.*/
String voternameParam = request.getParameter("votername");
System.out.println("the votername is " + request.getParameter("votername"));
System.out.println(voternameParam);
String votersurnameParam = request.getParameter("votersurname");
System.out.println("the votersurname is " + request.getParameter("votersurname"));
String hiddenrelationParam = request.getParameter("texthiddenrelation");
System.out.println("the relation is " + request.getParameter("texthiddenrelation"));
String parentnameParam = request.getParameter("parentname");
System.out.println("the parentname is " + request.getParameter("parentname"));
String parentsurnameParam = request.getParameter("parentsurname");
System.out.println("the parentsurname is " + request.getParameter("parentsurname"));
String ageParam = request.getParameter("age");
System.out.println("the age is " + request.getParameter("age"));
String mergedageParam = request.getParameter("mergedage");
System.out.println("the mergedage is " + request.getParameter("mergedage"));
String hiddensexParam = request.getParameter("texthiddensex");
System.out.println("the hiddensex is " + request.getParameter("texthiddensex"));
//String dobParam = request.getParameter("dob");
//System.out.println("the dob is " + request.getParameter("dob"));
String finaladdressParam = request.getParameter("finaladdress");
System.out.println("the finaladdress is " + request.getParameter("finaladdress"));
String pincodeParam = request.getParameter("pincode");
System.out.println("the pincode is " + request.getParameter("pincode"));
String stateParam = request.getParameter("state");
System.out.println("the state is " + request.getParameter("state"));
String cityParam = request.getParameter("city");
System.out.println("the city is " + request.getParameter("city"));
String constituencyParam = request.getParameter("constituency");
System.out.println("the constituency is " + request.getParameter("constituency"));
String refnoParam = request.getParameter("refno");
System.out.println("the refno is " + request.getParameter("refno"));
System.out.println("encoding = " + System.getProperty("file.encoding"));
public String getvotername()
return request.getParameter("votername");
public String getvotersurname()
return request.getParameter("votersurname");
public String getvoterrelation()
return request.getParameter("texthiddenrelation");
public String getparentname()
return request.getParameter("parentname");
public String getparentsurname()
return request.getParameter("parentsurname");
public String getage()
return request.getParameter("age");
public String getsex()
return request.getParameter("texthiddensex");
public String getadderess()
return request.getParameter("finaladdress");
public String getpin()
return request.getParameter("pincode");
public String getstate()
return request.getParameter("state");
public String getcity()
return request.getParameter("city");
public String getconst()
return request.getParameter("constituency");
public String getrefno()
return request.getParameter("refno");
public String getdob()
return request.getParameter("mergedage");
public String getpic()
//String a=request.getParameter("pic");
//a=a.substring(a.lastIndexOf("/")+1);
//System.out.print("Java path is "+a);
//Enumeration enum=request.getFileNames();
//while(enum.hasMoreElements())
// String abc=(String)enum.nextElement();
// System.out.print("Java the path is "+abc);
return request.getParameter("pic");
String votername1;
//public void setScope()
//request.setAttribute("votername1" ,voternameParam );
//insertEntry.jsp
<jsp:useBean id="logicbean" class="pack.logicbean" scope="request"/>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.util.*,java.text.*" %>
<%@ page import="com.oreilly.servlet.*" %>
<%
request.setCharacterEncoding("UTF-8");
%>
<!-- Perform the actions on the bean. -->
<%
request.setCharacterEncoding("UTF-8");
%>
<%
try
/* Set the request object.*/
/* The request object is implicitly available in the JSP page.*/
logicbean.setRequest(request);
//MultiPartRequest mp=MultiPartRequest(request,"E:\Files");
/* Insert the employee data into the database.*/
logicbean.insertEntry();
/* Run the query to retrieve the employee data from the database.*/
//logicbean.runQueryInsert();
catch (Exception e)
System.out.println(e.getMessage());
%>
<HTML>
<HEAD>
<TITLE>
Insert Record
</TITLE>
</HEAD>
<BODY background="brown.bmp">
<center><H2><%=session.getValue("ie.label")%>
</H2>
<font face = "Devanagari MT for IBM" size = +2>
<b><%=session.getValue("ie.sd")%>|<%=session.getValue("ie.home")%></b>
</font>
</center>
</BODY>
</HTML>
I have narrowed down the problem to the point where i understand that the "request.getParameter()" function for multipart is not able to understand or read UTF data properly. The out.println prints garbage from this function on the console. im using WAS
plz help
thanx in advance
caffainehi,
To solve your problem Servlet Filters
FILTER PROGRAM
===============
package filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;
public class SetCharacterEncodingFilter implements Filter {
// ----------------------------------------------------- Instance Variables
* The default character encoding to set for requests that pass through
* this filter.
protected String encoding = null;
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
protected FilterConfig filterConfig = null;
* Should a character encoding specified by the client be ignored?
protected boolean ignore = true;
// --------------------------------------------------------- Public Methods
* Take this filter out of service.
public void destroy() {
this.encoding = null;
this.filterConfig = null;
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
// Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
// Pass control on to the next filter
chain.doFilter(request, response);
* Place this filter into service.
* @param filterConfig The filter configuration object
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;
// ------------------------------------------------------ Protected Methods
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding</strong> initialization parameter for this
* filter.
* @param request The servlet request we are processing
protected String selectEncoding(ServletRequest request) {
return (this.encoding);
web-xml entry
+++++++++++
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping> -
Multipart/form-data and file attachment
Hi ,
This question has probably been asked before, but if not then here it is. Any replies will be appreciated:
Q. When using "Enctype=Multipart/form-data", with file attachment alongwith other form fields, is it mandatory to attach a file ? What if user selects no file to attach?
Q. If no, then how can it be possible that a form can be submitted without attaching a file since when I try to submit a form with no file attached to it, it gives me error message saying :java.lang.NullPointerException
Q. Does it mean that I can't have a form with a blank "File" input field, if the form's Enctype is "multipart/form-data"? Since users may not select a file to attach to the form, in other words it is an optional.
I hope I was clear enough in explaining my questions.
Thanks in advance.I am using Orielly's file attachement pacakge.
Here's what I am doing in my JSP page: It does the following:
int maxFileSize = 10 * 1024 * 1024; // 5MB max
String uploadDir = "/direct/files/upload/";
String FormResults = "";
String FileResults = "";
String fileName = "";
String fileName2 = "";
String paramName="";
String paramValue="";
File f;
int filecounter=1;
first get the form fields using following code:
MultipartRequest multi = new MultipartRequest(request, uploadDir, maxFileSize);
Enumeration params = multi.getParameterNames();
//Get the form information
while (params.hasMoreElements())
paramName = (String) params.nextElement();
paramValue = multi.getParameter(paramName);
if (paramName.equals("emailconfirm"))
emailconfirmation = paramValue;
else if (paramName.equals("Requester"))
Requester = paramValue;
else if (paramName.equals("TodaysDate"))
TodaysDate = paramValue;
else if (paramName.equals("Extension"))
}//end while
Then it gets the file information using the following code: I have two file fields in my form so that's why I am using a filecounter to find out if user has attached two files or just one:
Enumeration files = multi.getFileNames();
while (files.hasMoreElements())
String formName = (String) files.nextElement();
if (filecounter == 2)
fileName2 = multi.getFilesystemName(formName);
String fileType = multi.getContentType(formName);
f = multi.getFile(formName);
FileResults += "<BR>" + formName + "=" + fileName2 + ": Type= " + fileType + ":
Size= " + f.length();
else
{ fileName = multi.getFilesystemName(formName);
String fileType = multi.getContentType(formName);
f = multi.getFile(formName);
FileResults += "<BR>" + formName + "=" + fileName + ": Type= " + fileType + ":
Size= " + f.length();
filecounter=filecounter+1;
Then after composing the mail message I send email with the form fields and file attachments using following code:
Properties props = new Properties();
MimeBodyPart mbp1 = new MimeBodyPart();
MimeBodyPart mbp2 = new MimeBodyPart();
MimeBodyPart mbp3 = new MimeBodyPart();
URLDecoder urlDecoder = new URLDecoder();
String to1 = urlDecoder.decode(toemail);
String from1 = urlDecoder.decode(fromemail);
String cc1 = urlDecoder.decode(ccemail);
props.put( "mail.host", host );
Session session1 = Session.getDefaultInstance(props, null);
// Construct the message
Message msg = new MimeMessage( session1 );
msg.setFrom( new InternetAddress( from1 ) );
msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse( to1, false ) );
msg.setRecipients( Message.RecipientType.CC, InternetAddress.parse( cc1, false ) );
msg.setSubject( subject );
msg.setHeader( "X-Mailer", "ExceptionErrorMail" );
msg.setSentDate( new Date() );
mbp1.setText(mail_message);
mbp1.setContent(mail_message, "text/html");
// Send the email message
FileDataSource fds = new FileDataSource(uploadDir + fileName);
FileDataSource fds2 = new FileDataSource(uploadDir + fileName2);
mbp2.setDataHandler(new DataHandler(fds));
mbp3.setDataHandler(new DataHandler(fds2));
mbp2.setFileName(fileName);
mbp3.setFileName(fileName2);
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
mp.addBodyPart(mbp3);
msg.setContent(mp);
Transport.send( msg );
//email sent...
//delete the two files from the server..
File f2 =new File(uploadDir + fileName);
f2.delete();
File f3 =new File(uploadDir + fileName2);
f3.delete();
//End of code
So when I don't attach a file and submit my form , I get the error message that I mentioned in my previous post.
Any more ideas? -
What is multipart/form-data ?
what is multipart/form-data ?
generally A form have some input fields and a submit button ? but what is
multipart/form-data ? or is it same thing ?http://www.w3.org/TR/REC-html40/interact/forms.html
enctype = content-type
This attribute specifies the content type used to submit the form to the server (when the value of method is "post"). The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file". -
Hi, I am using HP11 and iPlanet web server. When trying to upload files over HTTP using FORM ENCTYPE="multipart/form-data" that are bigger than a few Kilobytes i get a 408 error. (client timeout). It is as if the server has decided that the client has timed out during the file upload. The default setting is 30 seconds for AcceptTimeout in the magnus.conf file. This should be ample to get the file across, even increasing this to 2 minutes just produces the same error after 2 minutes. Any help appreciated. Apologies if this is not the correct forum for this, I couldn't see one for iPlanet and Web, many thanks, Kieran.
Hi,
You didnt mention which version of IWS. follow these steps.
(1)Goto Web Server Administration Server, select the server you want to manage.
(2)Select Preference >> Perfomance Tuning.
(3)set HTTP Persistent Connection Timeout to your choice (eg 180 sec for three minutes)
(4) Apply changes and restart the server.
*Setting the timeout to a lower value, however, may prevent the transfer of large files as timeout does not refer to the time that the connection has been idle. For example, if you are using a 2400 baud modem, and the request timeout is set to 180 seconds, then the maximum file size that can be transferred before the connection is closed is 432000 bits (2400 multiplied by 180)
Regards
T.Raghulan
[email protected] -
Upload a file to the server - multipart/form-data ?
I need to upload a file from my local machine to the server from a jsp page. I was asked to use a form with ENCTYPE = "multipart/form-data". but I am not sure how it works. Can any one enlighten me on the process or is there any other way to do it.
nullYou can find the jsp source & the java sources which exactly does that in the iFS CMS sample code section. Go to Products -> Internet File system -> sample code -> Content Management System. This application allows the user to upload files from a local file system into iFS. This application creates the file in the iFS repository. You may want to save it in the file system of the web server. You may have to make little changes but the functionality is exactly what you are looking for.
Hope this helps.
Rajesh -
Multiple select multipart/form-data + FileUploader
Hi
I'm using asp multiple select form field with
multipart/form-data +
FileUploader to upload a file (works fine) and writing the
contents of
a form to a database which works fine apart from the multiple
select
which although allows me to select multiple items only
returns the
first selected item to the database.
Anywork arounds to this??
Thanks in advance!!
Buzby
There's nothing more dangerous than a resourceful idiotMulti-part requests are not packaged the same as regular requests, so the getParameter() method doesn't work on it (although I think it would get anything passed through the query string as part of the action parameter but I'm not sure).
You can also try the com.oreilly.servlet class MultipartRequest. I don't know if that's the same one found in the www.servlets.com link, but it is REALLY easy. Essentially, it looks like this:
MultipartRequest mr = new MultipartRequest(request, "[pathtosavefiles]'");
String param = mr.getParameter("paramname");
So instead of calling getParameter() on the request object, you now instead call it on the MultipartRequest object. When you instantiate the MultipartRequest object, it parses the request body for you, and also saves any uploaded files into the directory you specified in your path in the constructor.
I hope that helps.
Michael -
Having garbage characters while using enctype="multipart/form-data"
Hi to all! =)
I'm uploading a CSV file in JSP ny adding [enctype="multipart/form-data"].
<html:form method="POST" action="/upload.do" enctype="multipart/form-data">Now, I have a problem on handling Japanese Characters. (becomes garbage)
I have declared a UTF-8 charset above my JSP
[<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="Shift_JIS" %>]Using
System.out.println(response.getCharacterEncoding());in my action, I get "ISO-8859-1" instead of UTF-8
I don't have any clue why this has happened. Can someone teach me how to override the "ISO-8859-1" coding.
Any suggestions will be deeply appreciated.Hi to all! =)
I'm uploading a CSV file in JSP ny adding [enctype="multipart/form-data"].
<html:form method="POST" action="/upload.do" enctype="multipart/form-data">Now, I have a problem on handling Japanese Characters. (becomes garbage)
I have declared a UTF-8 charset above my JSP
[<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="Shift_JIS" %>]Using
System.out.println(response.getCharacterEncoding());in my action, I get "ISO-8859-1" instead of UTF-8
I don't have any clue why this has happened. Can someone teach me how to override the "ISO-8859-1" coding.
Any suggestions will be deeply appreciated. -
H:form enctype="multipart/form-data" gets removed
I tried to create a file upload page using tomahawk 1.1.6, JSF RI 1.2_05-b06-FCS and facelets.
What I found is that the h:form removes the enctype="multipart/form-data" when rendering the JSF page.
In the resulting html page the enctype is entirely missing.
As a result the fileupload doesn't work, since the browser doesn't even send the file.
I read that JSF doesn't support multipart messages, but with this behaviour it prevents other libs like tomahawk accomplishing this task. Does anyone know whether there a way to solve this issue other then patching the FormRenderer?
regards,
ArturPlease log an issue [1] (if possible include a test case as an attachement).
[1] https://javaserverfaces.dev.java.net/issues
Maybe you are looking for
-
"save as jpeg" not working for only certain images (pse 2.0)
I've searched for hours, trying to figure this issue out, but there seems to be no answers to my particular perdiciment. So I guess I'll start a new discussion with hopes to find any answer that can lead me in the right direction. For some reason,
-
i downloaded a vector file from Shutterstock. How do I edit the text in Photoshop? If i enlarge the image- the pixels are awful and the image is distorted.
-
How to do one comp on multiple tracks..
I may be missing the an obvious feature, but I can't work out how to apply the same comp to multiple tracks. I.e. I record an instrument with more then one mic and am left with several tracks of the same take however from different microphone and pos
-
I looking for information on how others employ version control on all the various portal resources. Versioning custom development around remote services and the like is easily handled through the IDE or normal version control practices. What I am won
-
Automatic send e-mail according to the expire data attribute in database
Hi, everyone. I am now working a web library system, and I use MS Access as the database to store the data. Now I want to build a function for the system, which can automatic send loan expire message to the borrower when the expire data is met. I hav