Passing a file to an applet...

Hi guys,
i've developed a jsf application and i've loaded in it an applet for
visualizing some data.
My example applet load a file with a specified path and name i've on my
hd.
What i want is passing from my jsf application to applet the file i
want visualizing..
This is my jsf page
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<title>
HTML Test Page
</title>
</head>
<body>
<br>
<center>
<applet code="vdaoengine.TestApplet.class"  width=500 height=500>
<param name=bgcolor value="000000">
<param name=fgcolor1 value="ff0000">
<param name=fgcolor2 value="ff00ff">
<param name="datfile" value =
"file:///c:/workspace/MicroArray/WebContent/pages/data.dat">
<param name="settings_file" value = "file:elmap.ini">
<param name="microarray_type" value = "CGH_minimal_regions_gain_loss">
<param name="archive" value = "VDAOEngine.jar">
</applet>
</center>
</body>
</html> with
<param name="datfile" value =
"file:///c:/workspace/MicroArray/WebContent/pages/data.dat"> i pass the file data.dat.
How can i pass a file stored in a bean?
Please help me,thanks very much

Hello,
This is how I passed to a listener (IncidentFactoryBean) a property called incidentPk from bean "Incident":
    <h:commandLink id="retrieveIncident" action="retrieveIncident" actionListener="#{IncidentFactoryBean.retrieveIncident}" rendered="true">
        <h:outputText value="#{bundle.incidentList_retrieveIncident}" />
        <f:param id="curIncidentPk" name="curIncidentPk" value="#{incident.incidentPk}" />
    </h:commandLink>So in your example:
<f:param id="myUrl" name="myUrl" value="#{file.name}" />Is it what you are looking for??? Or didn't I understand the question?

Similar Messages

  • Passing a file as parameter from applet to servlet

    hi
    i have just started to use servlets. i have developed applet gui interface. when i click the button i want a file "abc.txt" to be send to the servlet. i am doing like this:
    URL serv_url = new URL(null,"http://host:port/xyz/servlet/TestServlet);
    URLConnection connect = (URLConnection)serv_url.openConnection();
    output = new File("abc.txt");
    connect.setDoOutput(true);
    connect.setDoInput(true);
    connect.setUseCaches(false);
    connect.setDefaultUseCaches(false);
    connect.setRequestProperty("content-type","application/x-www-form-urlencoded");
    ObjectOutputStream outputToServlet = new ObjectOutputStream(connect.getOutputStream());
    outputToServlet.writeObject(output);
    outputToServlet.flush();
    outputToServlet.close();
    //for printing purpose on the gui listbox          
    listmodel1.addElement("ConnectingToRemoteServlet");
    BufferedReader in = new BufferedReader ( new InputStreamReader (connect.getInputStream()));
              while((line = in.readLine())!= null)
              listmodel1.addElement("Response:"+line);
              in.close();
    but i am not sure if this is correct. because when i tried to print the file that is send to servlet. it is giving some ascii characters...
    please tell me how to make sure if the file has reached the servlet. or any other method!!
    thanks
    pre_pra

    i don't want to use any third party packages to achieve this. I have looking into forums and i understand that some object serialization stuff has to be done. but i am still not clear abt how to proceed. any example code or details of steps regarding to pass file object from applet to the servlet would be greatly appreciated. i have already spend two full days on this. i wish i can get a better understanding wiht you help
    thanks a lot:)

  • Submitting a user's file to an applet.

    Hi,
    I am fairly new to Java, but I have spent a large part of this year learning about and using Java to write a program for biochemists, to allow them to study a particular class of enzymes. I have used Java because I wanted to enable to program to be used by people via the internet, and I wanted there to be a good graphical interface. Java Applets have enabled me to do this. Furthermore, some of the computation has to be done via the server, because the Applet interfaces to a Prolog program, and again this was easy with Java, because I was able to do this using (HTTP interface) Servlets.
    There is one major drawback to this solution. The users will often develop 'models' of their enzyme, which they will want to save to a file, and reload at a later stage. However, Applets cannot access the user's file system, which means I had to find another way to achieve this. At the moment, loading (and saving) the models is done in a two-step process. A form, embedded in the web page below the Applet, is used to submit the file to a Servlet, which saves the contents of the file to a session object. Then, the user clicks on a button in the Applet, which connects to another Servlet, and the file is read from the session object, and transmitted back to the Applet. Saving a file is just the reverse of this process.
    Quite apart from the fact that it is a nuisance to do this transaction in two steps, it causes problems when the user doesn't have cookies turned on. I can always alert people to the fact that they need to turn cookies on (or use URL encoding), but it still means that there are two steps to the process.
    Does anyone have any suggestions how I might be able to write this sequence so that the user can load or save a file in only one step, instead of two? Someone suggested that I use sockets, but from the reading that I have done, it seems that Servlets are simply a convenient way to use sockets. So, it seems using sockets would just be a more difficult and time-consuming way to achieve the same end.
    Any suggestions on this topic would be gratefully appreciated.
    Regards,
    Sarah

    Thanks so much for your prompt reply.
    Every time the user performs an action in the applet that connects to one of the servlets, I extend the lifetime of their session object. That way, when they submit a file to the server, it is available for them to access it for a couple of hours, before the session object will time out (unless the user accesses the server in the meantime, which resets the lifetime of the session to 2hrs).
    The problem isn't actually passing the file from the servlet to the applet (or vice versa) - I already use IO streams to do this. The problem is can I get the file from the HTML form to the applet in one step?
    As far as I can see, if the connection to the servlet comes from the html form, then the response goes back to the browser. Similarly, if the request comes from the applet, the response goes back to the applet. What I am wondering is, is there a way to force communication from a servlet to the applet when the initial connection to the servlet has come from the browser (i.e. from the HTML form)?

  • Passing a value to an Applet from another server directory

    this is my problem:
    1) on our server we are logging a unique session_id: e.g: abc12345
    2) i want to pass the session_id value to the the applet.html file which calls applet.class
    Question:
    1) Can the applet.html file be in a different direcory from the applet.class file_?
    OR
    2) Would i have to use Javascript to pass the session_id value to applet.html_?
    ananda

    thanks smg123 - thats very helpful. I've tried experimenting with fixed URL's etc - and i keep getting security exceptions.
    In the following simple Applet.html code - could you give us a clue on how we would call Applet.class with Applet.html in a seperate directory - of course, keeping in mind that the Applet.class file is within Applet.jar_?
    ananda
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <h1>test</h1>
    <applet
    codebase="com.esdu.glenrowan.viewpacs.J9611A10.userinterface.J9611A10Applet.class"
    code="J9611A10Applet.class"
    archive="J9611A10.jar"
    width=695 height=525>
    </applet>
    </body>
    </html>

  • Is it possible to pass a string from an applet to the web site?

    Hi, everybody!
    Is it possible to pass a String from an applet to a web site (as a field value in a form, an ASP variable, or anything else). Basically, I have a pretty large String that is being edited by an applet. When a user clicks on the submit button, a different page will show up which has to display the modified string. The String is pretty large so it doesn't fit into the URL variable.
    Please, help!
    Thank you so much!

    Why do you want to do this in Java?
    Javascript is the correct language for these type of situations.
    for instance:
    in the head of your html document:
    <script language=javascript type="text/javascript">
    createWindow(form){
    if(form.text.value!=""){
    newDoc = new document
    newDoc.write(form.text.value)
    newWin = window.open(document,'newWin','width=200;height=150')
    </script>
    in the body:
    <form onSubmit="createWindow(this)">
    <p>
    Enter a String:<input type=text size=30 name="text">
    </p><p>
    <input type=submit value="submit"> 
    <input type=reset value="reset">
    </p>
    </form>

  • How do I update a file in an Applet's JAR file from the Applet code

    Here's my problem.
    My applet is using a serializable history data in which I am storing in the applet's JAR file. When I run the applet, I read the file with "getResourceAsStream()" and run my program with that hist data. When my applet is closed, I need to update this file from my Applet's code and I dumfounded about how to do that.
    Is there any way to update a file in the Applet's JAR file through the Java Applet code? (i.e. OutputStream?).
    Would appreciate any advice people have.

    Just place a copy of the file on the local hard disk and update that. When you start the Applet you try to read from the hard disk. If the file exists then no problem otherwise copy it from the jar to the hard disk.

  • Reading and writing to a text file from an Applet

    I'm a novice java programming with very little formal programming training. I've pieced together enough knowledge to do what I've wanted to do so far...
    However, I've been unable to figure out how to read and write to a text file from an Applet (I can do it from a normal java program just fine). Here is a simple example of what I'd like to do (you can also look at it on my website: www.stat.colostate.edu/~leach/test02/test02.html). I know that there is some problem with permission/security but I'm not smart enough to understand what the error messages are telling or understand the few books I have. If anyone can tell me how to get this applet to work, or direct me to some referrences that would help me out I'd really appreciate it.
    Thanks,
    Andy
    import java.applet.Applet;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    public class test02 extends Applet {
    public Button B_go;
    public GridBagConstraints c;
    public void init() {
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    B_go = new Button("GO");
    c.gridx=1; c.gridy=0; c.gridwidth=1; c.gridheight=1;
    c.weightx = c.weighty = 0.0;
    B_go.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    print_stuff();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.add(B_go,c);
    public static void print_stuff() {
    try{
    File f = new File("test02.txt");
    PrintWriter out = new PrintWriter(new FileWriter(f));
    out.print("This is test02.txt");
    out.close();
    }catch(IOException e){**/}
    }

    I have almost the exact same problem, and I am in the same situation as you are with respects to the language.
    I am simply trying to create a file and output some garbage to it but my applet always spits back a security violation. I've tried eliminating the restrictions on the applet runner I use but I still get the error.
    My method:
    debug = new Label() ;
    debug.setLocation( 20, 20 ) ;
    debug.setSize( 500, 15 ) ;
    add( debug ) ;
    // output
    try
         OutputStream file = new FileOutputStream( new File( "" + getCodeBase() + "output.txt" ) ) ;
         byte[] buffer = { 1, 2, 3, 4, 5 } ;
         file.write( buffer ) ;
         file.close() ;
    } catch( Exception e )
         debug.setText( e.toString() ) ;
         Can anyone tell why this isnt working?

  • Pass in file name as parameter

    Can canyone help me in how to pass the filename as parameter? I have a list of xml files so i hope to pass the files. Does anyone have a code sample of showing me how to do? Thanx

    i have a java program that is to print out the xml files such as Declaration.xml, Aviation.xml and Financial.xml so i hope to create a class that is to pass in these file names to this program.

  • How to call a java method so I can pass a file into the method

    I want to pass a file into a java method method from the main method. Can anyone give me some help as to how I pass the file into the method - do I pass the file name ? are there any special points I need to put in the methods signature etc ?
    FileReader file = new FileReader("Scores");
    BufferedReader infile = new BufferedReader(file);
    Where am I supposed to put the above text - in the main method or the one I want to pass the file into to?
    Thanks

    It's a matter of personal preference really. I would encapsulate all of the file-parsing logic in a separate class that implements an interface so that if in the future you want to start taking the integers from another source, e.g. a db, you wouldn't need to drastically alter your main application code. Probably something like this, (with an assumption that the numbers are delimited by a comma and a realisation that my file-handling routine sucks):
    public class MyApp{
    public static void main(String[] args){
    IntegerGather g = new FileIntegerGatherer();
    Integer[] result = g.getIntegers(args[0]);
    public interface IntegerGatherer{
    public Integer[] getIntegers(String location);
    import java.io.*;
    public class FileIntegerGatherer implements IntegerGatherer{
    public Integer[] getIntegers(String location){
    FileInputStream fs=null;
    try{
    File f = new File(location);
    fs = new FileInputStream(f);
    byte[] in = new byte[1024];
    StringBuffer sb = new StringBuffer();
    while((fs.read(in))!=-1){
    sb.append(new String(in));
    StringTokenizer st = new StringTokenizer(sb.toString(),",");
    Integer[] result = new Integer[st.countTokens()];
    int count = 0;
    while(st.hasMoreTokens()){
    result[count]=Integer.valueOf(st.nextToken());
    count++;
    catch(IOException e){
    //something sensible here
    finally{
    if(fs!=null){
    try{
    fs.close();
    catch(IOException f){
    return result;
    Once compiled you could invoke it as java MyApp c:\myInts.txt
    Sorry if there are typos in there, I don't have an ide open ;->

  • Passing a file from one page to another

    Hello,
    I have a page in the application, which uploads a file.
    I need to pass this file to another page, where it's going to be inserted in the table with some other parameters.
    Is there a way to do it in Apex?
    for example a temporally table that could store the file for later use??
    Thank you for consideration.

    Here is a good tutorial on BLOBS.
    http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm
    You may want to upload your file to a file storage table with some sort of sequence. You can store the value of the sequence and pass it across to the next page and look it up to re-insert (or better yet just add a foreign key reference).

  • How to pass a file into a java method

    I am trying to pass a file into a java method so I can read the file from inside the method. How can I do this? I am confident passing int, char, arrays etc into methods as I know how to identify them in a methods signature but I have no idea how to decalre a file in a mthods signature. Any ideas please ?
    Thanks

    Hi,
    Just go thru the URL,
    http://www6.software.ibm.com/devtools/news1001/art24.htm#toc2
    I hope you will get a fair understanding of 'what is pass by reference/value'.
    You can pass Object reference as an argument.
    What Pablo Lucien had written is right. But the ideal situation is if you are not modifying the
    file in the calling method, then you can pass the String (file name) as an argument to the called method.
    Sudha

  • Add a jar file to an Applet

    Hi all,
    I'm trying to add a .jar file to my applet using the code:
    <applet name=myApplet.class archive=model.jar></applet>
    Both the .class and .jar files are in the same directory as test.html
    So, when the applet starts an exception is thrown:
    java.lang.NoClassDefFoundError: it/bizware/session/interfaces/HardwareLogManagerUtil
         at AppletPistolaL.getHardwareLogManager(AppletPistolaL.java:222)
         at AppletPistolaL.init(AppletPistolaL.java:97)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    The model.jar contains the path it/bizware/session.../HardwareLogManagerUtil!
    I can't understand why this exception is thrown
    Someone can help me?!?!?!
    thanks a lot!!

    Solved,
    just to add all path it/bizware/....
    and works!!!!
    bye!

  • Exporting to a text file in an applet..

    Hey all,
    I've been working on an applet for simulating different nodal configurations on a 2D map. What I need to be able to do is export, on the click of a button, all of the nodal coordinates (x,y) to a text file. However, using the standard FileWrite hasn't been working for me. The code compiles and the applet runs fine, but I haven't been able to create the text file on the click of a button. Any ideas?
    Here's what I've got so far. Basically, on the button push, it's supposed goes through an array of ellipses (what I use for nodes) and gets the x and y coords for each and output them to a text file. The applet doesn't freeze or anything when I push the button either, it just does nothing.
    void stop_actionPerformed(ActionEvent e){
                try
                        String fileName = "NodeCoords.txt";
                        FileWriter fileWriter = new FileWriter( fileName );
                        BufferedWriter bufferedWriter = new BufferedWriter( fileWriter );
                        String tmpCoordinates;
                        int ID;
                        //for looop through x-y coordinates
                        for (int i = 0; i < node.length; i++){
                            ID = i+1;
                            tmpCoordinates = "Node: " + String.valueOf(nodeID[ID]) + "  X: " + String.valueOf(node.getX()) + " Y: " + String.valueOf(node[i].getY()) + "\n";
    bufferedWriter.write(tmpCoordinates);
    bufferedWriter.close();
    catch( IOException p )
    p.printStackTrace();

    I'm new to this type of programming. This is for simulation of a new MAC protocol that I've worked on, and is basically just serving as a visual. If I knew how to create a stand alone application that looks like the applet I would have...

  • How to pass parameter from javascript to applet ?

    i have some parameters from form in html,
    and i would like to pass from javascript to an applet,
    (which a type of calling method in applet from javascript)
    and get back data from applet to display in html
    how could i do this ?

    in my program,
    i pass 3 string to the applet
    var reply = document.test.called(ft, fc, tc)
    in the fucntion "called" in the "test" applet
    i simply test it by
    public String called(String l, String from, String to){
    return "abcd";
    but the result should the value return is "1"
    can anyone help me ?

  • Passing a file via File Adapter without renaming.

    We have a scenario whereby we pick up a file locally using a file adapter set up as a sender in local NFS file mode, and then pass that file through PI without mapping or conversion to XML.
    We would like to send the file via a file adapter set up as a receiver in FTP mode, and to use the filename that was recognised by the sending adapter. However, I cannot see a way to do this.
    is this possible?
    - Tony.

    Hi,
    The problem is, as I see it, that the File Receiver in FTP mode expects a naming convention that will not provide what er want to do.
    e.g. File sender processes a file EDI00001.txt. We want to send that file via the File Receiver in FTP mode with that filename, EDI00001.txt.
    Next file picked up from file sender has name EDI00002.txt. We want that sent via FTP as EDI00002.txt, etc etc.
    Problem is, it seems there is no way to tell the File Receiver to use the file name that the File Sender picked up.
    BR,
    Tony.

Maybe you are looking for