Problem with session while sending a multipart-form (a file via post)

I have a problem with the communication between my applet and my server. I use a method to post an xml to my server with the Content-Type "application/x-www-form-urlencoded" and with it I'm not having any problem to preserve the session.
However I use another method I found in the forums to post files and try to adapt it, but I'm being send from the server to the login page because it's not recognizing my session
Can anybody help me? This is my method
public String uploadFile(String adr, BufferedImage img) {
        String res = "";
        String CONTENT_BOUNDARY = "--abvx98734732";
        String s;
        File f = null;
        URL url;
        URLConnection conn;
        try {
            url = new URL(adr);
            conn = url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestProperty("Content-Type",
                    "multipart/form-data; boundary=" + CONTENT_BOUNDARY);
            conn.setRequestProperty("file-Name", "process_image.jpg");
            DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
            wr
                    .write(("--"
                            + CONTENT_BOUNDARY
                            + "\r\n"
                            + "Content-Disposition: form-data; name=\"fileData\"; filename=\""
                            + "process_image.jpg" + "\"\r\nContent-Type: image/jpg\r\n\r\n")
                            .getBytes());
            ImageIO.write(img, "jpg", wr);
            wr.write(("\r\n--" + CONTENT_BOUNDARY + "--\r\n").getBytes());
            wr.flush();
            BufferedReader in = new BufferedReader(new InputStreamReader(conn
                    .getInputStream()));
            while ((s = in.readLine()) != null) {
                res += s;
            in.close();
        catch (MalformedURLException muo) {
            muo.printStackTrace();
        catch (IOException io) {
            io.printStackTrace();
        return res;
    }This is how I preserve session in my other method:
private static final String SESSION_KEY = "_session_id";
URLEncoder.encode(SESSION_KEY, "UTF-8") + "=" +
URLEncoder.encode(sessionId, "UTF-8");
wr.writeBytes(content);
....

Yes, the only way is to pass the value u want in the query string. But make sure that the value is not too large.
In case you have too much info i guess the only way is to circumvent multipart and handle the process in your own custom class, which wont be worth the effort if u need pass only 2-3 small parameters.
Always,
Leo.
Hi,
Before I upload a file, I want to get a few parameter
values (getParameter) on the form first. I've tried
using com.oreilly.servlet MultipartRequest and a few
other free servlets but they require that the file
must to be uploaded first. For example:
MultipartRequest multi = new
MultipartRequest(request,filepath, 10*1024*1024);
//this will instantiate the object and upload the
file
String command = multi.getParameter("command"); //get
the form parameter
Is there any way I can get the parameter first before
uploading the file? I truly appreciate any helps you
can provide me.
Regards,
Lily

Similar Messages

  • Problem with &amp while sending xml as string to webservice

    Hi I am also facing a problem I want to send a string to my sap webservice into the following format
    <DATA><STRUCTURE VAL="FLASH"><VALUEPART VAL="40100"></VALUEPART></STRUCTURE><STRUCTURE VAL="FLEX"><VALUEPART VAL="2000"></VALUEPART></STRUCTURE></DATA>
    But whenever I am sending this string to my webservice in webservice it is reading this data like
    &amp;lt;DATA&gt;&amp;lt;STRUCTURE VAL="FLASH"&gt;&amp;lt;VALUEPART VAL="40100"&gt;&amp;lt;/VALUEPART&gt;&amp;lt;/STRUCTURE&gt;&amp;lt;STRUCTURE VAL="FLEX"&gt;&amp;lt;VALUEPART VAL="2000"&gt;&amp;lt;/VALUEPART&gt;&amp;lt;/STRUCTURE&gt;&amp;lt;/DATA&gt;
    Please help me to solve the problem .

    Thanks for your reply but now I am using escape(srting) and server side script reading it as
    %3CDATA%3E%3CSTRUCTURE%20VAL%3D%22FLASH%22%3E%3CVALUEPART%20VAL%3D%2240100%22%3E%3C/VALUEP ART%3E%3C/STRUCTURE%3E%3CSTRUCTURE%20VAL%3D%22FLEX%22%3E%3CVALUEPART%20VAL%3D%222000%22%3E %3C/VALUEPART%3E%3C/STRUCTURE%3E%3C/DATA%3E
    I have to send this as
    <DATA><STRUCTURE VAL="FLASH"><VALUEPART VAL="40100"></VALUEPART></STRUCTURE><STRUCTURE VAL="FLEX"><VALUEPART VAL="2000"></VALUEPART></STRUCTURE></DATA>
    any other option ?

  • Problem with Sessions in JSP

    Hi,
    I am working on a JSP based website, where I am facing problem with sessions. The user is asked to login by providing her id and password. If found correct, a bean is created and populated with all her details and placed in session scope. I plan to use the information stored in the bean on other related pages until she logs out.
    <jsp:useBean id="validUser" scope="session" class="UserBean" >
    <c:set target="${validUser}" property="userId" value="${fn:trim(dbValues.UserId)}" />
    <c:set target="${validUser}" property="userName" value="${fn:trim(dbValues.UserName)}" />
    </jsp:useBean>
    <c:redirect url="userHome.jsp" /> The user is presented her homepage - 'userHome.jsp', where she can find various links, like 'Update Profile', 'Pay Registration Fees', 'Book Room' etc. The information stored in the bean is available on 'userHome.jsp'page.
    <A HREF='userHome.jsp'>Home</A>
    <A HREF='editPersonal.jsp'>Update Profile</A>
    <A HREF='registrationFee.jsp'>Pay Registration Fees</A>
    <A HREF='bookRoom.jsp'>Book Room</A>
    <A HREF='logout.jsp'>Logout</A> The problems are:
    1. Whenever user clicks on any of the above mentioned links and moves to any page, the bean comes out as null.
    <%-- Verify that the user is logged in --%>
    <c:if test="${validUser == null}">
    <jsp:forward page="loginForm.jsp">
    <jsp:param name="origURL" value="${pageContext.request.requestURL}" />
    <jsp:param name="errorMsg" value="You must be logged in to access this site." />
    </jsp:forward>
    </c:if> 2. The URL shows an additional jsessionid, which my client doesn't want to see.
    3. On every click on any link, the value of this jsessionid changes.
    What I presume, when I am clicking on different links, my session changes, and so I am seeing a different jsessionid. And since session is changing, therefore the bean is not available in a different session.
    All this works fine with localhost, problem comes into picture, when I upload my pages to the server.
    Puzzled, can anyone help, where am I going wrong? Let me add here, I am new to JSP and hence don't have much resources with me.

    There are several ways sessions can be exchanged between the browser and the server in a j2ee web application.
    1. The default is through cookies. However when the client does not accept cookies, the server appends the session id to the url.
    2. Some servers also facilitate session information exchange using session id in the url even if the client does accept cookies. This is usually ahieved through a setting in some server configuration file.
    You will have to find out why the server in your application is appending the session id to the url.
    Whatever be the case, the server should be able to look up the session from the incoming request (be it from the session id in the url or a session cookie).
    When session information is exchanged through the JSESSIONID in the url, you should ensure that each and every url that goes to the server has this input parameter. To do that all links and form post urls in your servlet/jsp should be treated with a call to encodeURL().
    For example, in a jsp
       <a href = "<%=response.encodeURL("/nextJsp.jsp")%>">Click here </a>
    or
       <form action = "<%=response.encodeURL("/nextJsp.jsp")%>">
       </form>etc.
    ram.

  • Problem with sessions in Kate Editor

    Hey guys!
    I'm using Kate Editor to code and i'm having problems with sessions. If kate is open and I logout KDE, when I come back to KDE all my customizations in Kate's session (activated plugins, font size, etc) are lost.
    If I manually close Kate before logout from KDE, all the customizations are kept when a manually start Kate. I tried a lot of workarounds, but none worked.
    Is this a bug? Someone else with this issue?
    Thanks in advance!

    The Warning errors are simply because you don't have the tablespaces, users, and roles defined in your application system under the DB Admin tab. Unless it is important to you to capture the physical implementation of your tables exactly as well as the table definitions, you can safely ignore these. If the physical implementation IS important to you, then you need to create these tablespaces, roles and users under the database that you created under the DB Admin tab before you start the capture.
    The Error is because in the set of objects you are capturing there is a foreign key that references the table named "PLEASANT". This table must be among the objects that you are capturing, or must already be in a Table Definition in your application system in the repository.

  • TS3276 I receive a pop up from ICal saying the server does not recognize me user name and password.  This started yesterday.  I have no problems with receiving or sending emails through Mail

    I receive a pop-up from ICal saying the server does not recognize my user name and password for my me.com email address.  This started yesterday and occurs about every 5 minutes or so.  There are no problems with receiving or sending email through Mail.  I did change me email password several days ago but have no problems sending/receiving since then.

    I fixed the problem.  I opened Preferences in ICal and entered my new password.  No more pop-ups

  • Compilation problem with templates while using option -m64

    Hi,
    I have compilation problem with template while using option -m64.
    No problem while using option -m32.
    @ uname -a
    SunOS snt5010 5.10 Generic_127111-11 sun4v sparc SUNW,SPARC-Enterprise-T5220
    $ CC -V
    CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
    Here is some C++ program
    ############# foo5.cpp #############
    template <typename T, T N, unsigned long S = sizeof(T) * 8>
    struct static_number_of_ones
    static const T m_value = static_number_of_ones<T, N, S - 1>::m_value >> 1;
    static const unsigned long m_count = static_number_of_ones<T, N, S - 1>::m_count + (static_number_of_ones<T, N, S - 1>::m_value & 0x1);
    template <typename T, T N>
    struct static_number_of_ones<T, N, 0>
    static const T m_value = N;
    static const unsigned long m_count = 0;
    template <typename T, T N>
    struct static_is_power_of_2
    static const bool m_result = (static_number_of_ones<T,N>::m_count == 1);
    template <unsigned long N>
    struct static_number_is_power_of_2
    static const bool m_result = (static_number_of_ones<unsigned long, N>::m_count == 1);
    int main(int argc)
    int ret = 0;
    if (argc > 1)
    ret += static_is_power_of_2<unsigned short, 16>::m_result;
    ret += static_is_power_of_2<unsigned int, 16>::m_result;
    ret += static_is_power_of_2<unsigned long, 16>::m_result;
    ret += static_number_is_power_of_2<16>::m_result;
    else
    ret += static_is_power_of_2<unsigned short, 17>::m_result;
    ret += static_is_power_of_2<unsigned int, 17>::m_result;
    ret += static_is_power_of_2<unsigned long, 17>::m_result;
    ret += static_number_is_power_of_2<17>::m_result;
    return ret;
    Compiation:
    @ CC -m32 foo5.cpp
    // No problem
    @ CC -m64 foo5.cpp
    "foo5.cpp", line 20: Error: An integer constant expression is required here.
    "foo5.cpp", line 36: Where: While specializing "static_is_power_of_2<unsigned long, 16>".
    "foo5.cpp", line 36: Where: Specialized in non-template code.
    "foo5.cpp", line 26: Error: An integer constant expression is required here.
    "foo5.cpp", line 37: Where: While specializing "static_number_is_power_of_2<16>".
    "foo5.cpp", line 37: Where: Specialized in non-template code.
    "foo5.cpp", line 20: Error: An integer constant expression is required here.
    "foo5.cpp", line 43: Where: While specializing "static_is_power_of_2<unsigned long, 17>".
    "foo5.cpp", line 43: Where: Specialized in non-template code.
    "foo5.cpp", line 26: Error: An integer constant expression is required here.
    "foo5.cpp", line 44: Where: While specializing "static_number_is_power_of_2<17>".
    "foo5.cpp", line 44: Where: Specialized in non-template code.
    4 Error(s) detected.
    Predefined macro:
    @ CC -m32 -xdumpmacros=defs foo5.cpp | & tee log32
    @ CC -m64 -xdumpmacros=defs foo5.cpp | & tee log64
    @ diff log32 log64
    7c7
    < #define __TIME__ "09:24:58"
    #define __TIME__ "09:25:38"20c20
    < #define __sparcv8plus 1
    #define __sparcv9 1[snipped]
    =========================
    What is wrong?
    Thanks,
    Alex Vinokur

    Bug 6749491 has been filed for this problem. It will be visible at [http://bugs.sun.com] in a day or two.
    If you have a service contract with Sun, you can ask to have this bug's priority raised, and get a pre-release version of a compiler patch that fixes the problem.
    Otherwise, you can check for new patches from time to time at
    [http://developers.sun.com/sunstudio/downloads/patches/]
    and see whether this bug is listed as fixed.

  • Strange Problem In NWDS while devloping  Adobe Offline Form

    I am facing a strange problem in NWDS while devloping Offline Adobe Form, the implementation code gets erased once the project is deployed, even the source file also gets deleted.

    self

  • I have a problem with session manager session files because of the invalid json storage data submited by firefox

    Hi, i have problem with session manager's session files. The problem is: the submitted storage data from firefox which is put between "storage":{ and its matching closing brace } But in some of my session files there is non equal { and } under storage's braces. I need to get storage data but in my case it is very hard to do. My question is there any char put before or after { and } like /{ or \{ to avoid confusion? If there is not such thing, i think there could be different solution but i am not sure: i look couple of my session files; after "storage":{...} there is ,_"formDataSaved" so i can get storage data in this example ... by looking between "storage":{ and ,"_formDataSaved" easily. Is there every time ,"_formDataSaved" after "storage":{ ?  Thank you.

    Well, it seems waiting is not my strong suit..! I renamed a javascript file called recovery to sessionstore. This file was in the folder sessionstore-backups I had copied from mozilla 3 days ago, when my tabs were still in place. I replaced the sessionstore in mozilla's default folder with the renamed file and then started mozilla. And the tabs reappeared as they were 3 days ago!
    So there goes the tab problem. But again when I started mozilla the window saying "a script has stopped responding" appeared, this time the script being: chrome//browser/contenttabbrowser.xml2542
    If someone knows how to fix this and make firefox launch normally, please reply! Thank you

  • Hello. I have problem here can someone plz help. I have usb of 32 gb but i have problem with it while i was trying to partition of it and it fails and my usb disappear from finder and desktop i have tried every possible thing but nothing  works .

    Hello. I have problem here can someone plz help. I have usb of 32 gb but i have problem with it while i was trying to partition of it and it fails and my usb disappear from finder and desktop i have tried every possible thing but nothing  works .

    Yea i tried in disk utility and its got faiiled and the partitation has deleted and when i tried  to replug the  usb  msg show up by saying  usb not compaitnle. With this mac  and  take me to disk utility  and thanks for replying

  • Can anyone please help me, I'm having problems with sound while watching video clips using flash player using Internet Explorer\

    Can anyone please help me, I'm having problems with sound while watching video clips using flash player & Internet Explorer

    There's a good chance that this is a known issue.  We'll have a Flash Player 18 beta later this week that should resolve this at http://www.adobe.com/go/flashplayerbeta/

  • Problem with Photoshop CS6. If I open a file using Camera RAW

    I have a new problem with Photoshop CS6.  If I open a file using Camera RAW, and process it as usual, CS6 doesn't want to save it the way it used to.  I don't know if I changed something by accident or not. 
    Here's what happens now: After opening from ACR to CS6 and completinhg all of my work, I choose "Save as..."  The save as window opens showing the file name and format.  The default format seems to be .PSD.  I use the drop down to select .jpg.  The file saves normally as a .jpg.  When I go to close the image from, I get a new prompt asking, "Save changes to Adobe Photoshop document DSC_xxxx.NEF before closing?
    I looked up at the file name in the bar above the work space and noticed that it does NOT change from "DSC_xxxx.NEF" to "DSC_xxxx.jpg" after I have saved the file as a .jpg,in my webesite  but it always used to do that.  This adds a few extra steps when closing a document and it really slows me down.
    In fact, I wouldn't swear to this, but I think it used to save to .jpg by default, without me specifying this.
    I don't see a setting in the preferences for what to use as the default file format for saving, so I don't know where to change it back.
    Any ideas?
    Thanks in advance

    You are in the wrong forum;  You actually need Photoshop forum at this link:
    <http://forums.adobe.com/community/photoshop?view=discussions>
    Hope you can repost your question at the correct link.

  • Problems With Data Alignment when spooling to a CSV file

    Dear members,
    I am spooling data to a csv file. My data contains 3 columns
    For example :
    col1 col2 col3
    USD,10000033020000000000000,-1144206.34
    The 2nd column is alphanumeric, it contains some rows which have only numbers and some which have numbers and alphabets.
    The 3rd column contains only numbers with positive or negative values.
    I am facing problem with alignment. when i open the spooled csv file then i find that the 3rd column is aligned to right .
    In the 2nd column, rows which have only numbers are right justified and rows which have alpha numeric data are left justified.
    I tried using the JUSTIFY function in sql plus but still it is not working for me.
    Can any body give your opinion on how to control the alignment in spooled csv files.
    Your responce is highly appreciated.
    Here is my code :
    WHENEVER SQLERROR CONTINUE
    SET TIMING off
    set feedback off
    set heading off
    set termout OFF
    set pagesize 0
    set linesize 200
    set verify off
    set trimspool ON
    SET NEWPAGE NONE
    col to_char(glcd.segment1||glcd.segment2||glcd.segment3||glcd.segment4||glcd.segment5||glcd.segment6) ALIAS CONCATENATED_SEGMENTS
    col CONCATENATED_SEGMENTS justify left
    col to_char(decode(glbal.currency_code,glsob.currency_code,
    (begin_balance_dr - begin_balance_cr) + (period_net_dr -period_net_cr),
    (begin_balance_dr_beq - begin_balance_cr_beq) + (period_net_dr_beq -period_net_cr_beq))) alias Total_Functional_Currency
    col Total_Functional_Currency justify left
    COlUMN V_INSTANCE NEW_VALUE V_inst noprint
    select trim(lower(instance_name)) V_INSTANCE
    from v$instance;
    column clogname new_value logname
    select '/d01/oracle/'|| '&&V_inst' ||'out/outbound/KEMET_BALANCE_FILE_EXTRACT' clogname from dual;
    spool &&logname..csv
    SELECT glsob.currency_code ||','||
    to_char(glcd.segment1||glcd.segment2||glcd.segment3||glcd.segment4||glcd.segment5||glcd.segment6) ||','||
    to_char(decode(glbal.currency_code,glsob.currency_code,
    (begin_balance_dr - begin_balance_cr) + (period_net_dr -period_net_cr),
    (begin_balance_dr_beq - begin_balance_cr_beq) + (period_net_dr_beq -period_net_cr_beq)))
    from gl_balances glbal , gl_code_combinations glcd , gl_sets_of_books glsob
    where      period_name = '&1' /* Period Name */
    and      glbal.translated_flag IS NULL
    and      glbal.code_combination_id = glcd.code_combination_id
    and      glbal.set_of_books_id = glsob.set_of_books_id
    and      glbal.actual_flag = 'A'
    and      glsob.short_name in ('KEC-BOOKS' , 'KUE' , 'KEU','KEMS', 'KEAL' , 'KEAL-TW' , 'KEAL-SZ' , 'KEAM')
    and glcd.segment1 != '05'
    and decode(glbal.currency_code , glsob.currency_code , (begin_balance_dr - begin_balance_cr) + (period_net_dr -period_net_cr) ,
    (begin_balance_dr_beq - begin_balance_cr_beq) + (period_net_dr_beq -period_net_cr_beq)) != 0
    and glbal.template_id IS NULL
    ORDER BY glcd.segment1 || glcd.segment2 || glcd.segment3 || glcd.segment4 || glcd.segment5 || glcd.segment6
    spool off
    SET TIMING on
    set termout on
    set feedback on
    set heading on
    set pagesize 35
    set linesize 100
    set echo on
    set verify on
    Thanks
    Sandeep

    i think you do not have to worry about your code when you say that the plain texts created are ok when opened on the notepad. it is on the excel that you will need some adjustments. not sure about this but you might want to read about the applying styles in the excel by going through it's help menu.

  • Problem with converting .RIFF : I still cannot  transfer RIFF file to ipod

    Snitch
    Posts: 13
    From: Cali
    Registered: Feb 13, 2006
    Problem with converting .RIFF to mpeg4 even tho its a mpeg
    Posted: Jun 2, 2006 2:19 PM
    1st problem trying to convert mpeg video thru ipod converter. I have successfully converted DVD`s and other downlaoded videos but this is the 1st time i ran into a wall.
    I am using GSPOT CODEC software and it says its a "riff- wrapped " file. When I open up Videora converter it doenst do anything meaning no green bars to show its progressing into mpeg4 format. It does finish and it goes to finish videos but when I try to manually put it in my I-tunes it doenst do anything. Why i am posting this. I am frustrated. WHAT -and it appears to be mpeg - the heck is RIFF wrapped file? Please help I have GUNS n ROSES live at ritz 1988 rare footage andI want it on my ipod and It does play in my windows media player so its a true video with sound
    Intel P4 Windows XP Black 60 GB Video w/ Agent 18 shield
    Johnathan Burger
    Posts: 1,450
    Registered: Jul 27, 2005
    Re: Problem with converting .RIFF to mpeg4 even tho its a mpeg
    Posted: Jun 3, 2006 1:38 AM in response to: Snitch
    Never heard of RIFF, so I did research and found these sources: http://ccrma.stanford.edu/courses/422/projects/WaveFormat/
    http://en.wikipedia.org/wiki/RIFF
    Good luck.
    17" iMac 1.8ghz G5 2GB 12 iBook 1.2ghz 512mb 5th gen iPod Mac OS X (10.4.6) Microsoft Free since '92
    Pages: 1 Back to Topic List

    See:
    iOS: Troubleshooting applications purchased from the App Store
    Contact the developer/go to their support site
    Restore from backup. See:
    iOS: How to back up              
    Restore to factory settings/new iPod

  • TS3297 My downloaded song stops suddenly halfway through. I assume there was a problem with the download. Can I download the file again??

    My downloaded song stops suddenly halfway through. I assume there was a problem with the download. Can I download the file again?? Will I have to purchase the song again?

    You need to delete the current copy of the broken track from your library before it will be offered up for download. It may help to close and reopen iTunes.
    If the problem persists and you can't get a good version of the file contact the iTunes Store support staff through the report a problem links in your account history, or via Contact Support.
    tt2

  • I am facing lots of problems with security while using Mozilla. How can I send you a detailed report for this?

    I am getting redirected to unknown sites whenever I open any site while using mozilla. Initially I thought that there is a problem with my device, but then I realized that this happens only when using mozilla, not with other browsers like chrome, IE, or opera.
    These sites are mainly having the message 'Ad by ShopDrop'..
    I am pasting below links to few sites to which I get redirected to
    http://offers.bycontext<i></i>.com/scjs/tb/ctxjs/index<i></i>.php?kw2=www.espncricinfo<i></i>.com&affid=1151&subaff_id=725_724&intformat=roll&nextpage=http%3A%2F%2Fwww.espncricinfo<i></i>.com%2F&ch=421&sbrand=ShopDrop&folder=v4.19&typrd=ctx&cu=32929&country=IN&original_country=IN
    http://add0n<i></i>.com/fastest-gmail.html?v=0.1.6&p=0.1.5&type=upgrade

    hello, you have various malicious addons present. please perform all these steps:
    # [[Reset Firefox – easily fix most problems|reset firefox]] (this will keep your bookmarks and passwords)
    # afterwards go to the firefox menu ≡ > addons > extensions and in case there are still extensions listed there, disable them.
    # finally run a full scan of your system with different security tools like the [http://www.malwarebytes.org/products/malwarebytes_free free version of malwarebytes] and [http://www.bleepingcomputer.com/download/adwcleaner/ adwcleaner] to make sure that adware isn't present in other places of your system as well.
    [[Troubleshoot Firefox issues caused by malware]]

Maybe you are looking for

  • Exception in calling a web service from a composite application service

    Hi, I have created a composite application service with external service as a web service. My web service is deployed on localhost as well as I am running my composite application service in localhost. When i try to test the application service, I ge

  • Adobe Acrobat 9 Pro - Form Toolbar

    There has been a big change from Acrobat 8 Pro to 9 Pro regarding how the forms toolbar is displayed.  While the changes are a great improvement to make it easier to create forms...I am having trouble adjusting to editing forms.  Is there any way to

  • HT4759 Y can't I get my iCloud to work

    Y can't I get my iCloud to work

  • Using apple ID and itune cards

    Can you create an Apple ID with out putting in a physical address and will it work with itunes and pre paid itunes cards and free stuff at apps store.

  • Single alert for error from multiple BPM call

    Hi all, we have following scenario (using BPM): IDOC -> XI -> sync web service ->XI-> IDOC. In case of WS failure (destination system is not answering) an alert should be triggered on XI. There is one customer restriction that the alert can be trigge