Please help me to write a file from applet to server with a servlet.

In an applet the client elaborates a string and stores it in the variable of the name "line"
I would Like to write the string "line" in the file myfile.txt on the server.
I am in an applet trying to make the URLconnection to a servlet.
The part of the applet which calls the servlet is the following:
private void writeToSer(String line)
try
URL u = new URL("http://192.168.1.103:8180/servlet/ScriviFileServletFor1?stringa="+line);
HttpURLConnection urlConn = (HttpURLConnection)u.openConnection();
catch(IOException ioe)
JOptionPane.showMessageDialog(null,"IO Exception ","attenzione",JOptionPane.ERROR_MESSAGE );
the code of the servlet is the following:
import java.io.*;
import java.io.File;
import javax.servlet.*;
import javax.servlet.http.*;
public class ScriviFileServletFor1 extends HttpServlet {
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//read the parameters
String string = request.getParameter("stringa");
try {
File file = new File("/home/icurrado/myfile.txt");
FileWriter out = new FileWriter(file);
out.write(string);
out.close();
catch (Exception e) {
e.printStackTrace();
When I call the servlet from the bar of the URL with :
http://localhost:8180/servlet/ScriviFileServletFor1?stringa=prova
It works and writes the string "prova" in the file "/home/icurrado/myfile.txt".
When I call the servlet from the applet it doesn't work and it doesn't write the string in the file.
What is wrong or is missing ?
Please help me.

You dont need to go through the URL mechanism.
From an Applet you can directly save the file on the server at destinated location.
You can look for "Uploader Applet" in google.

Similar Messages

  • How can I write to files from applets?

    I want to write a capability into a game i'm writing that allows it to keep track of high scores. I am fairly certain that I will need to write to a file separate from the applet and then read it back in later. How can I do this? I don't think typical input/output streams work. Any helps or tips on how to set up a high scores list would be helpful!
    thanks a lot!

    Hi,
    Firts sign the applet or jar file.
    public void NxFileOpen(String ElFichero) {
    String ElError="";
    NxExportarPath=ElFichero;
    try {
    NxExportarFile = new FileWriter(ElFichero,false);
    } catch (IOException NxError) {
    ElError="No puedo abrir el fichero :"+NxExportarPath+".";
    } catch (SecurityException NxError) {
    ElError="No puedo acceder al fichero :"+NxExportarPath+ " para abrir. (Seguridades java)";
    } catch (Exception NxError) {
    ElError="Error. Fichero = "+NxExportarPath+". Accion = OPEN.";
    if (ElError!="") {
    System.out.println(ElError);
    NxExportarFile = null;
    public void NxFileClose() {
    String ElError="";
    try {
    NxExportarFile.close();
    } catch (IOException NxError) {
    ElError="No puedo cerrar el fichero :"+NxExportarPath+".";
    } catch (SecurityException NxError) {
    ElError="No puedo acceder al fichero :"+NxExportarPath+ " para cerrar.(Seguridades java)";
    } catch (Exception NxError) {
    ElError="Error. Fichero = "+NxExportarPath+". Accion = CLOSE.";
    if (ElError!="") {
    System.out.println(ElError);      
    NxExportarFile = null;
    public void NxFileSave(int Dato) {
    String ElError="";
    try {
    NxExportarFile.write(Dato);
    } catch (IOException NxError) {
    ElError="No puedo grabar en el fichero :"+NxExportarPath+".";
    } catch (SecurityException NxError) {
    ElError="No puedo acceder al fichero :"+NxExportarPath+ " para grabar. (Seguridades java)";
    } catch (Exception NxError) {
    ElError="Error. Fichero = "+NxExportarPath+". Accion = WRITE.";
    if (ElError!="") {
    System.out.println(ElError);      
    NxExportarFile = null;
    I hope help you

  • Help needed to write control file.

    Hi Guys,
    i need to write one control file to upload data from .txt file to oracle table.
    .txt file data contains like this
    2006041110:40:22
    2006041111:30:42
    2006041210:40:22
    i need to upload this data into date column in oracle table.
    please help me to write control file for this requirement.
    Thanks for your help and time

        data1        "to_date(:data1, 'YYYYMMDDHH24:MI:SS')"

  • Please help: Example how to peploy application from jar file step by step

    Please help: Example how to peploy application from jar file step by step.
    All help appreciated
    Mike

    Thanks I will try these links
    Mike
    "Slava Imeshev" <[email protected]> wrote:
    Hi Mike,
    These links could be useful:
    http://e-docs.bea.com/wls/docs61////adminguide/appman.html
    http://e-docs.bea.com/wls/docs61////quickstart/quick_start.html
    http://e-docs.bea.com/wls/docs61//////ConsoleHelp/application.html
    http://e-docs.bea.com/wls/docs61///programming/environment.html
    Regards,
    Slava Imeshev
    "Mike" <[email protected]> wrote in message
    news:3ca0e94c$[email protected]..
    Please help: Example how to peploy application from jar file step bystep.
    All help appreciated
    Mike

  • Write HTML Files from java application

    Hello,
    i have to write HTML files from a java application.
    I am asking if anybody can give me a hint about a good simple solution (library) which can do some of the job for me.
    i know FOP for example is good to create pdf or html from xml, but i dont want to go via xml.
    the sites i need are really very simple presents emails.
    body and maybe a link for next and pervious.
    however, thank you in advance.
    a little hint will also help :)
    Sako.

    That, too, is my question.
    Be the "server" local or remote, wouldn't JSPs still
    be the easier solution? No. it will not. because you need a server. Server for a stand alone application is not esier. according to who said JSPs are easy?
    Its very very difficult.
    >
    When answering, please clarify. I'm a bit of a newbie
    here. :)To get sence about how hard is JSP, check Struts. this is very good open source Framework to simplify the JSPs. but it still complecated enough.
    or Tapestry my lovely open srouce Framework.
    its easier than Struts. but sill complecated because of the documentation.
    All in all, using JSP is the purpose of Java in the internet. but not for me. My application will not be available in the internet, i.e. no server, i.e. no need for JSP.
    i hope that helps a little.

  • Please help to re-write this query using exists or with

    Hi please help to re-write this query using exists or with, i need to write same code for 45 day , 90 days and so on but sub query condition is same for all
    SELECT SUM (DECODE (t_one_mon_c_paid_us, 0, 0, 1)) t_two_y_m_mul_ca_
    FROM (SELECT SUM (one_mon_c_paid_us) t_one_mon_c_paid_us
    FROM (
    SELECT a.individual_id individual_id,
    CASE
    WHEN NVL
    (b.ship_dt,
    TO_DATE ('05-MAY-1955')
    ) >= SYSDATE - 45
    AND a.country_cd = 'US'
    AND b.individual_id in (
    SELECT UNIQUE c.individual_id
    FROM order c
    WHERE c.prod_cd = 'A'
    AND NVL (c.last_payment_dt,
    TO_DATE ('05-MAY-1955')
    ) >= SYSDATE - 745)
    THEN 1
    ELSE 0
    END AS one_mon_c_paid_us
    FROM items b, addr a, product d
    WHERE b.prod_id = d.prod_id
    AND d.affinity_1_cd = 'ADH'
    AND b.individual_id = a.individual_id)
    GROUP BY individual_id)
    Edited by: user4522368 on Aug 23, 2010 9:11 AM

    Please try and place \ before and after you code \Could you not remove the inline column select with the following?
    SELECT a.individual_id individual_id
         ,CASE
            when b.Ship_dt is null then
              3
            WHEN b.ship_dt >= SYSDATE - 90
              3
            WHEN b.ship_dt >= SYSDATE - 45
              2
            WHEN b.ship_dt >= SYSDATE - 30
              1
          END AS one_mon_c_paid_us
    FROM  items           b
         ,addr            a
         ,product         d
         ,order           o
    WHERE b.prod_id       = d.prod_id
    AND   d.affinity_1_cd = 'ADH'
    AND   b.individual_id = a.individual_id
    AND   b.Individual_ID = o.Individual_ID
    and   o.Prod_CD       = 'A'             
    and   NVL (o.last_payment_dt,TO_DATE ('05-MAY-1955') ) >= SYSDATE - 745
    and   a.Country_CD    = 'US'

  • Please help me to write PCRs... can any body give on real time PCRs .......

    hi to all,
    can any one please help me to write the sample PCRs.

    hi thanks to that...
    but i need some simple PCRs from u r end ......
    please explain to me..
    u said that i need to learn operations and functions ..
    i know those but i don't know how to use it...
    i have had U000 schema material...
    but i am not understing .... it....
    so if u can explain the one or 2 sample PCRs so that i can develop with the help of them........
    waiting for u r soooooooooon replay.............
    bye
    ravi

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • I could not open my camera raw files from canon mark iii with my photoshop CS5. Tried to update Camera raw 6.7 but failed to install. Message said 'There was an error downloading this update. Please quit and try again later'. How could I open Raw files ?

    I could not open my camera raw files from canon mark iii with my photoshop CS5. Tried to update Camera raw 6.7 but failed to install. Message said 'There was an error downloading this update. Please quit and try again later'. How could I open Raw files ?

    Try installing it manually from:
    Adobe - Adobe Camera Raw and DNG Converter : For Windows : Camera Raw 6.7.1 Update
    Adobe - Adobe Camera Raw and DNG Converter : For Macintosh : Camera Raw 6.7.1 Update
    Regards,
    Ashutosh

  • I just bought iWorks Serial Number Key over the internet. When I use the key, iWorks tells me the key is invalid!! Please help. (I bought this iWorks from someone in Singapore. I am using it in Malaysia)

    I just bought iWorks Serial Number Key over the internet. When I use the key, iWorks keep telling me the key is invalid!! Please help. (I bought this iWorks from someone in Singapore. I am using it in Malaysia.). Thanks

    Downloaded the Trial version. It still says the serial number key is invalid. On the iWork page where I am suppose to enter the serial number key, the "Go Back" button is always BOLD, but the "Continue" button remains GREY all the time. The "Continue" button remains grey even after I have completed the key entry. I have to type the "Return" key on my keyboard to force enter the key. The message I get is still "Invalid key".
    I have called Apple. The first person helped by asking me to delete certain items in some Folders and it still did not work. I was then connected to a senior person, but I heard over the recording that there were 15 persons waiting on the line. I had to end the call because the wait will take too long.

  • HT3702 How can I stop and remove my credit card from my iPad ,my children keep buying games and I want to stop it......please help me to remove any payment from now on.

    How can I stop and remove my credit card from my iPad ,my children keep buying games and I want to stop it......please help me to remove any payment from now on.

    iOS: Understanding Restrictions
              http://support.apple.com/kb/HT4213

  • Can someone please help i cant connect to itunes from my iphone 4 ,,i had an iphone 3 and when i got my iphone 4 i changed my email address for new itunes account and my old phone which hubby uses

    Can someone please help i cant connect to itunes from my iphone 4 ,,i had an iphone 3 and when i got my iphone 4 i changed my email address for new itunes account and my old phone which hubby uses is changed aswell ..for some reason i cant update my apps off m iphone & in itunes via pc it will say apps are all up to date but i have 25 apps that need updating please can someone help ,, i can download a new app but i cant update existing ones ,,,
    very frustrated iphone user !!

    Changing devices is no reason to create a new Apple ID.
    All content purchased from iTunes is permanently linked to the Apple ID it was purchased with.
    To update apps purchased with the old ID, you MUST sign in with that Apple ID.

  • Please help me to change the language from Danish to swedish i PS CS5

    please help me to change the language from Danish to swedish i PS CS5
    In the program (interfaces) i can only choose Danish

    There is nothing to choose. The language is determined by your serial number and the choice of language during installation. You need to reinstall in that language.
    Mylenium

  • TS2446 Please help me,I can not purchase from apple store becuse it is ask me the secirty question in my apple ID but I forget my secrity question

    Hello,
    Please help me,I can not purchase from apple store becuse it is ask me about the secirty question in my apple ID but I forget my secrity question.
    Thanks,

    If you can't remember them then go to Express Lane  and select 'iTunes' from the list of 'products' in the middle of the screen.
    Then select 'iTunes Store', and on the next screen select 'Account Management'
    Next choose 'iTunes Store Account Security' and fill in that you'd like your security questions/answers reset.
    You should get an email reply within about 24 to 48 hours (and check your Spam folder as well as your Inbox). A month or two ago Apple had temporarily suspended the reseting of security question/answers whilst account security processes were improved, but that may now have finished.

  • TS1627 Please Help. I received 4 emails from 1 person with the same message heading. The emails were automatically grouped by Mail. I replied to the latest mail in the conversation. Once sent the other messages in the conversation disappeared. I NEED THEM

    Please Help. I received 4 emails from 1 person with the same message heading. The emails were automatically grouped Apple Mail. I replied to the latest mail in the conversation. Once sent the other messages in the conversation disappeared. I NEED THEM BACK! They all had very important attachments. I have tried looking for them in deleted items, even though I didn't throw any of them away, still cant find them. Never had this problem before. I'm pretty sure its a setting somewhere. Also tried expanding all conversations, no luck. Searching for the mails under the sent email address, no luck.
    I'm sure they are not deleted but have somehow been hidden by Mail. Very frustrating.
    Thanks in advance for any help.
    Kash.

    I have found found out what has happened. I had requested a statement dating back to April 2012 from a supplier. They replied back with the latest statementof 2013 only but used the same subject heading as the previous monthly statements. Apple Mail automatically grouped these and I thought that they were sent altogether. As soon as I replied to the last email all other the previous emails ungrouped from the conversation leaving me lost as to where they had gone. They were all still sitting in my inbox but no longer part of the trcked conversation. I searched under the subject heading and all individual mails were all still there. (feeling stupid - )

Maybe you are looking for