Can  Java be used to save content of HTML form to a file?

We have an application that saves a pdf file to a location on our webserver. The file displays on the users machine in a browser window. I have created a link in the links bar of the browser window which launches a simple HTML page. This page allows the user to enter a number of fields and click 'SAVE'. This is where I am having the problem. I need the save button to firstly create a csv file on the webserver containing the details input by the user. I then need the pdf file saved to the web server with a new name and in the same location as the csv file. is there anyway to achieve this using Java or can anyone please point me in the right direction?
Thanks

<<Click on the SAVE button in an HTML <form> and the browser will perform an HTTP POST of the data to a URL. Make that URL point to a Java servlet and it can take that form data
<<and write it to the webserver file system in any format you wish, including csv and pdf.
agree with duffy. You can also use JSP and call a class method to handle whatever data you specify.
orozcom

Similar Messages

  • Can Java be used to manipulate the Windows registry?

    Can Java be used to manipulate the Windows registry? If so, can someone point me to some examples?
    Thanks!

    There is no supplied capability to do this, because the registry is Windows platform specific.
    It might be possible by making the call through a native Windoze app.

  • How can an applet retrieve the values of a HTML form shown in a JEditorPane

    Hi,
    I'm doing an applet that contains a JTree and a JEditorPane
    among other components. Each node of the JTree represents some
    information that is stored in a database, and whenever a JTree
    node is selected, this information is recovered and shown in
    the JEditorPane with a html form. To make the html form,
    the applet calls a servlet, which retrieves the information of
    the node selected from the database. This information is stored
    like a XML string, and using XSLT, the servlet sends the html
    form to the applet, which shows it in the JEditorPane.
    My problem is that I don't know how I can recover new values
    that a user of the application can introduce in the input fields
    of the html form. I need to recover this new values and send them
    to another servlet which store the information in the database.
    If someone could help me I'd be very pleased.
    Eduardo

    At least I found a fantastic example. Here it is:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.net.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    public class FormSubmission extends JApplet {
    private final static String FORM_TEXT = "<html><head></head><body><h1>Formulario</h1>"
    + "<form action=\"\" method=\"get\"><table><tr><td>Nombre:</td>"
    + "<td><input name=\"Nombre\" type=\"text\" value=\"James T.\"></td>"
    + "</tr><tr><td>Apellido:</td>"
    + "<td><input name=\"Apellido\" type=\"text\" value=\"Kirk\"></td>"
    + "</tr><tr><td>Cargo:</td>"
    + "<td><select name=\"Cargo\"><option>Captain<option>Comandante<option>General</select></td>"
    + "</tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Enviar\"></td>"
    + "</tr></table></form></body></html>";
    protected HashMap radioGroups = new HashMap();
    private Vector v = new Vector();
    public FormSubmission() {
    getContentPane().setLayout(new BorderLayout());
    JEditorPane editorPane = new JEditorPane();
    editorPane.setEditable(false);
    editorPane.setEditorKit(new HTMLEditorKit()
    public ViewFactory getViewFactory() {
    return new HTMLEditorKit.HTMLFactory() {
    public View create(Element elem) {
    Object o = elem.getAttributes().getAttribute(javax.swing.text.StyleConstants.NameAttribute);
    if (o instanceof HTML.Tag)
    HTML.Tag kind = (HTML.Tag) o;
    if (kind == HTML.Tag.INPUT || kind == HTML.Tag.SELECT || kind == HTML.Tag.TEXTAREA)
    return new FormView(elem)
    protected void submitData(String data)
    showData(data);
    protected void imageSubmit(String data)
    showData(data);
    // Workaround f�r Bug #4529702
    protected Component createComponent()
    if (getElement().getName().equals("input") &&
    getElement().getAttributes().getAttribute(HTML.Attribute.TYPE).equals("radio"))
    String name = (String) getElement().getAttributes().getAttribute(HTML.Attribute.NAME);
    if (radioGroups.get(name) == null)
    radioGroups.put(name, new ButtonGroup());
    ((JToggleButton.ToggleButtonModel) getElement().getAttributes().getAttribute(StyleConstants.ModelAttribute)).setGroup((ButtonGroup) radioGroups.get(name));
    JComponent comp = (JComponent) super.createComponent();
    // Peque�a mejora visual
    comp.setOpaque(false);
    return comp;
    return super.create(elem);
    //editorPane.setText(FORM_TEXT);
    editorPane.setText(texto);
    getContentPane().add(new JScrollPane(editorPane), BorderLayout.CENTER);
    private void showData(String data) {
         // ergebnis significa resultado
    StringBuffer ergebnis = new StringBuffer("");
    StringTokenizer st = new StringTokenizer(data, "&");
    while (st.hasMoreTokens()) {
    String token = st.nextToken();
    String key = URLDecoder.decode(token.substring(0, token.indexOf("=")));
    String value = URLDecoder.decode(token.substring(token.indexOf("=")+1,token.length()));
    v.add(value);
    ergebnis.append(" "); ergebnis.append(key); ergebnis.append(": "); ergebnis.append(value); ergebnis.append(" ");
    ergebnis.append(" ");
    JOptionPane.showMessageDialog(this, ergebnis.toString());
    public static void main(String[] args) throws Exception {
    JFrame frame = new JFrame ();
    FormSubmission editor = new FormSubmission ();
    frame.getContentPane().add(editor);
    frame.pack();
    frame.show();
    }

  • How to use PO message type to output 'Form' as PDF file

    Dear experts,
      I am working for a topic of how to use PO message type to output 'Form' as 'PDF file', and save to external file system automatically.
      Any one familiar to this topic, please kindly give me some guide, thank you!
    Regards,
    Joyce

    Hi,
       Go through the program RSTXPDFT4 (Converting SAPscript (OTF) or ABAP List Spool Job to PDF), you will get some idea.  Using this program you can convert spool into PDF file.
    -Alpesh

  • Want to submit contents of a form to a file how to do it?

    want to submit contents of a form to a file how to do it?
    i have a RSS form contents are :
    Channel, its id,url,desc,etc.
    then item,its id,url,desc etc.
    when i say submit i have to submit all the contents.
    Now add these contents to a class called item.
    how do i do this actually.
    sholud i start with Jsp>submit>any file who handles all data>send to item.java
    or directly i say submit and item.java will get the contents.
    after getting this data from jsp page which item.java all get methods can get i have to do rest of the process.ading deleting ,parsing etc.
    i am working with Rss Feed if anyone wants have a look on this.
    http://informa.sourceforge.net/quickstart.html
    Parsing an RSS Feed is topic here.
    Please give me the flow of porgram.
    Can be much helpful if you write some smaal lines of code to guide i need hint after that i will write everything.
    The only problem is how to start.
    rest i will do.
    thanks
    VJ

    For now what i have done is a form having (RSS) input types as channel(title,link,desc) with many items together(title,link,desc)
    here i submitted the form to a servlet.to add to a file created a filehandler as well. but now problem is how to add many items to file together. Onechannel with many items sholud get uploaded to filehandler which will create a RSS file structure.On the basis of input.
    at the time of addition in a channel item can be 1-5 with all fileds (title,link desc) now how sholud i iterate them all.
    please if someone can suggest me anything please let me know.
    vijendra

  • How can i convert  my invoice which is in smart forms to xml file

    how can i convert  my invoice which is in smart forms to xml file.

    Hi Anil,
    Please go through this link:
    1. XSF stands for XML for Smart Forms. It is important to contrast XSF with .... The eDocx script engine can provide a script to convert the file format to an 
    http://www.ossincorp.com/Black_Box/Black_Box_4.htm
    please rewrds if found helpful.
    Regards,
    Alok

  • Can Java be used to parse Microsoft Word(.doc) files?

    Hi guys ,
    I want to know whether Java can be used to parse Microsoft Word(.doc) files for searching a string or for checking for grammatical errors, etc
    Thanks in advance.
    Avichal

    Hey man, anything and every thing can be done these days.
    About ur question doc is like all other normal text files with some extra features and extra character supports and other stuffs.
    If u neglect those parts and if u consider it to be a normal text file then its a much simpler job.
    Here is a code that searches for the key word in all the doc files, txt files, pdf files and html files
    in the mentioned folder and sub folders. Any way its a servlet u can change it to a normal program.
    It first check the file to know whether they are doc, pdf, html or txt files if yes then it will read the file and
    store the contents in the vector and parse the vector for the search string and display the result.
    Along with the result the below code will also display the time taken and the number of search string found in the document
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class search_local extends HttpServlet
         public void service( HttpServletRequest _req, HttpServletResponse _res ) throws ServletException, IOException
              long startTime = System.currentTimeMillis();          
              File RootDir     = new File( _req.getRealPath( "/docs/" ) );
              if ( RootDir.isDirectory() == false )
                   System.out.println( "Invalid directory" );
                   _res.setStatus( HttpServletResponse.SC_NO_CONTENT );
                   return;
              Vector kList = new Vector( 3 );
              StringTokenizer st = new StringTokenizer( _req.getParameter( "search_text" ), "+" );
              while ( st.hasMoreTokens() )
                   kList.addElement( st.nextToken().trim() );
              //- Run through list
              Vector toBeDone     = new Vector( 10 );
              Vector found     = new Vector( 10 );
              String dir[] = RootDir.list( new htmlFilter() );
              cDirInfo tX = new cDirInfo( RootDir, dir );
              toBeDone.addElement( tX );
              while (  toBeDone.isEmpty() == false )
                   tX = (cDirInfo)toBeDone.firstElement();
                   try
                        int x = 0;
                        for ( ;; )
                             File newFile = new File( tX.rootDir, tX.dirList[x] );
                             if ( newFile.isDirectory() )
                                  File t = new File( tX.rootDir, tX.dirList[x] );
                                  String a[] = newFile.list( new htmlFilter() );
                                  toBeDone.addElement( new cDirInfo( t, a ) );
                             else
                                  int freq = searchFile( kList, newFile );
                                  if ( freq != 0 )
                                       found.addElement( new cPage( freq, newFile ) );                              
                             x++;
                   catch( ArrayIndexOutOfBoundsException E ){}
                   toBeDone.removeElementAt(0);
                   dir     = null;
              long totalTime = System.currentTimeMillis()     - startTime;
              formatResults( found, kList, totalTime, _req.getRealPath( "/docs" ), _res );
         private void formatResults( Vector _fList, Vector _kList, long time, String _root, HttpServletResponse _res ) throws IOException
                 _res.setContentType("text/html");
              PrintWriter Out = new PrintWriter( _res.getOutputStream() );
              Out.println( "<HTML><HEAD><TITLE>Search results</TITLE></HEAD>" );
              Out.println( "<BODY><H3>Search Results</H3><BR>" );
              Out.println( "Keywords:<B> " );
              Enumeration E = _kList.elements();
              while ( E.hasMoreElements() )
                   Out.println( (String)E.nextElement() + " : " );
              Out.println( "</B><BR><BR><CENTER><HR WIDTH=100%></CENTER><BR>" );
              E = _fList.elements();
              cPage sPage;
              String link;
              while ( E.hasMoreElements() )
                   sPage = (cPage)E.nextElement();
                   link  = sPage.cFile.toString();
                   link  = "http://localhost/BugFix/docs/" + link.substring( link.indexOf( _root )+_root.length(), link.length() );
                   Out.println( "<FONT SIZE=+1><A HREF=" + link + ">" + sPage.cFile.getName() + "</A></FONT>" );
                   Out.println( "<FONT SIZE=-2>(" + sPage.freq + ")</FONT><BR>" );
              if ( _fList.size() == 0 )
                   Out.println( "<I><B>No sites found!</I></B><BR>");
              Out.println( "<BR><CENTER><HR WIDTH=100%></CENTER>" );
              Out.println( "<BR><FONT SIZE=-1>Time to complete: " + ((double)time/1000) + " seconds</FONT>" );
              Out.println( "</BODY></HTML>" );
              Out.flush();
         private int searchFile( Vector _klist, File _filename )
              //- Links the file
              int     frequency=0;
              try
                   DataInputStream In     = new DataInputStream( new FileInputStream( _filename ) );
                   String LineIn, token;
                   boolean bValid = true;
                   Enumeration E;
                   cLineParse lp;
                   while ( (LineIn = In.readLine()) != null )
                        lp = new cLineParse( LineIn.toUpperCase() );
                        while ( (token=lp.nextToken()) != "" )
                             if ( token.indexOf( "<" ) != -1 && (
                                   token.indexOf( "<A" ) != -1 ||
                                   token.indexOf( "<HE" ) != -1 ||
                                   token.indexOf( "<APP" ) != -1 ||
                                   token.indexOf( "<SER" ) != -1 ||
                                   token.indexOf( "<TEX" ) != -1  ))
                                  bValid  = false;
                             else if (     token.indexOf( "<" ) != -1 && (
                                            token.indexOf( "</A" ) != -1 ||
                                            token.indexOf( "</HE" ) != -1 ||
                                            token.indexOf( "</APP" ) != -1 ||
                                            token.indexOf( "</SER" ) != -1 ||
                                            token.indexOf( "</TEX" ) != -1  ))
                                  bValid  = true;
                             else if ( bValid )
                                  E = _klist.elements();
                                  String key;
                                  while ( E.hasMoreElements() )
                                       key     = ((String)E.nextElement()).toUpperCase();
                                       if ( token.indexOf( key ) != -1 )
                                            frequency++;
                   In.close();
              catch( IOException E ){}
              return frequency;
    class cPage extends Object
         public int     freq;
         public File cFile;
         public cPage( int _freq, File _cFile )
              freq = _freq;
              cFile = _cFile;
    //- End of file
    //----- Supporting classes
    class htmlFilter implements FilenameFilter
         public boolean accept(File dir, String name)
              File tF     = new File( dir, name );
              if ( tF.isDirectory() )
                   return true;
              int indx = name.lastIndexOf( "." );
              if ( indx == -1 )
                   return false;
              String Ext = name.substring( indx+1, name.length() ).toLowerCase();
              if ( Ext.equals( "html" ) ||
                    Ext.equals( "pdf" ) ||
                    Ext.equals( "txt" ) ||
                    Ext.equals( "doc" ) )
                    return true;
              return false;
    class cDirInfo
         public File     rootDir;
         public String[] dirList;
         public cDirInfo( File _r, String[] _d )
              rootDir     = _r;
              dirList = _d;
    class cLineParse
         String L;
         public cLineParse( String _s )
              L = _s;
         public String nextToken()
              String ns="";
              boolean bStart = false;
              for ( int x=0; x < L.length(); x++ )
                   if ( L.charAt(x) == '<' && ns.length() != 0 )
                        L = L.substring( x, L.length() );
                        return ns;
                   else if ( L.charAt(x) == '<' )
                        ns     = ns + L.charAt( x );
                        bStart = true;
                   else if ( L.charAt(x) == '>' ||
                               L.charAt(x) == '\r' ||
                         ( L.charAt(x) == ' ' && bStart == false ) )
                        ns     = ns + L.charAt( x );
                        L = L.substring( x+1, L.length() );
                        return ns;
                   else
                        ns     = ns + L.charAt( x );
              L = "";
              return ns;
    }

  • Why i can not use f:param inside an html form?

    Hi
    Thank you for reading my post
    what is wrong with the following code ?
    <form action="https://www.3rdpartyWeb.com/CardServices/controller"
    method="GET" enctype="multipart/form-data"
                           name="submissionform">
        <f:param value="#{Session.MID}" name="MID" id="MID"/>
        <f:param value="#{ButtonsActionListener.reservationNumber}"
    name="ResNum" id="ResNum"/>
        <f:param value="#{Session.redirectURL}" name="RedirectURL"
    id="RedirectURL"/>
        <f:param value="#{ButtonsActionListener.total_price}" name="Amount"
    id="Amount"/>
                           </form>
        <SCRIPT type="text/javascript">
    document.forms["submissionform"].submit();
    </SCRIPT>while both ButtonsActionListener , Session are managed beans ,
    my question is , does the above form will post correctly to the named
    url along with parameters ?
    if not , how i can make this possible , i should say that i submit the
    form using javascript and no user interaction should be involved.
    do i used a correct design for this ?
    I should say that : i used some java script to show a progress bar in
    this page until the page submit to 3rd party web site.
    thanks

    Hi,
    you are mixing technologies here. You have a html form element that you want a JSF element to provide the input for.
    Frank

  • How to save contents of a JTextArea to a file without the newline blocks?

    Hello everyone
    I have created a GUI with a JTextArea and a button to save the contents of the JTextArea to a text file. I am working on a windows platform. Problem is that when saving the contents to the file, the newline block appears within the file ignoring the newline in the JTextArea.
    Is there a way of saving these contents the way they appear in the JTextArea preserving the format they are displayed? I want to create a file that looks exactly the way my JTextArea looks like.
    Up to the moment i am using the following code which produces a rather confusing file:
    save.addActionListener(
                        new ActionListener() {
                             public void actionPerformed(ActionEvent e) {
                                  String textCaptured = textArea.getText();
                                  File file = new File("Log.txt");
                                  try {
                                       BufferedWriter out = new BufferedWriter(new FileWriter(file));
                                       out.write(textCaptured);
                                       out.flush();
                                       out.close();
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();
                                  finally{
                                       JOptionPane.showMessageDialog(null,"Your log file has been created");
              );Thank you all in advance
    Christophoros

    Thanks uncle_alice.
    Your solution worked like a charm :)
    Have a nice day
    To anyone who might face similar problems heres the code:
    File file = new File("Log.txt");
                                  try {
                                       BufferedWriter out = new BufferedWriter(new FileWriter(file));
                                       textArea.write(out);
                                       out.flush();
                                       out.close();
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();

  • Can Java be used for this?

    Hi. As a hobby, I have built a game with a development tool called Macromedia Director.The game is a 'virtual tabletop' that allows people to play a variety of role playing games over the internet that are traditionally played in a face to face setting at a real table.
    Due to some shortcomings with Director I am looking for another language to program the game.I currently use an old version of Director and upgrading is expensive. Director also has limited cross platform support (no Linux). Finally, the future of Director is in question as Macromedia was acquired by Adobe and they have already end-of-lifed some of the acquired products.
    My game consists of some basic features. One user runs a server application that accepts connections from the client application. Once connected the cleints can do basis text chat. There is die rolling function. Finally there is a feature for the referee to send pregenerated images to the players, typically some sort of map. The image can be hidden from the players and revealed in pieces by the referee. I also plan on adding a shared whiteboard feature for creating on the fly images.
    I have done some preliminary investigation and it seems that Java is one of the obvious choices. The socket programming seems to be straight forward and allow you to create a similar client/server application. Swing covers building the GUI. What I am not clear on is the graphics capability of Java. Director has a fairly powerful graphics engine allowing you to work with 32 bit graphics (alpha channels) and pixel manipulation.
    It seems like Java can do all this, but I want to make sure before I invest to much time. You can see screen shots of my game at http://www.v-fort.org. It's definetly not a polished product. There are many of these types of programs already.I just do it because I enjoy programming (and gaming too). I appreciate any suggestions. Thanks
    -- Dave

    Java is it!

  • Can java be used for game dev?

    (Side note)-when I first posted here a couple months ago I decided to stop because of final exams.
    I want to get back into programming again and Im thinking about starting into java (again). My future hope is to eventually make a basic game. Can you do that with java because a lot of people tell me java 3d is a horrible and useless system.
    thanks

    If you're working on this project by yourself, I wouldn't recommend using Java 3D. It takes a lot of effort to get even simple 3D graphics working the way you want them to in Java 3D, and the learning curve is pretty steep. I don't have any experience with jogl, though, so I can't say whether or not its any better.
    - Adam

  • Can Java be used to communicate with hardware?

    I work with electronics as a hobby, but wish to interface with my electronics so I'm trying to find a programming language that has good API's for hardware communication(most likely through a serial or parallel port).
    Can this be done with Java? I really like java and the fact that it's platform independant.

    I work with electronics as a hobby, but wish to
    interface with my electronics so I'm trying to find a
    programming language that has good API's for hardware
    communication(most likely through a serial or parallel
    port).
    Can this be done with Java? I really like java and the
    fact that it's platform independant.I used the serial communications API, and it's not hard to use. The thing is you loose the platform independence when you use (it has some platform specific things)

  • Can Java be used to write service/daemon at solaris?

    I new to solaris server side developement, thinking not go back to c/c++ on solaris, to write the system service or daemon. Can I use java to achieve this instead of c/c++ ? Or where I can find the samples / resources about this?
    Thanks,
    Ben

    There is no reason you cannot write a daemon in Java. The cloudscape database daemon that was shipped with the original Forte for Java is written in Java. You need to decide if Java can give the the performance you require for your service/daemon, however.
    You can find some examples and an API for writing Java Daemons at:
    http://www.jcp.org/en/jsr/detail?id=96
    http://jakarta.apache.org/commons/sandbox/daemon/
    http://sourceforge.net/projects/telnetd/

  • Can Java be used to link client/server?

    Hello,
    I do not know a great deal about either subject but I was wondering whether there was any information online (or indeed a product...) which is Java based to provide a link between a client/server environment. Specifically in this case online, i.e. an online catalogue where clients can interrogate (i.e. search for products etc.) a server.
    Thank you for any help!
    Tom.

    an online catalogue where clients can interrogate
    (i.e. search for products etc.) a server.The short answer to your question is: "Yes, Java can be used to develop the product you mentioned."
    The longer question comes in how do you want the users to access the on-line catalogue?
    It can be made as simple as a generic browser accessing your catalog which can be complete with pictures, descriptions, searches, and purchase information...
    or any combination of complexity up to having to use a user developed applicatoin to hit your site. Java can be used to implement the entire range.

  • Can java be used to stream

    i can use java for fee readers but i have to stream a dvd can i do this with java are there an tutorials.
    also i it is a bit off java but you will probably be able to help me you know most things here. can i convert a mepg4 into a dvd playable format that can play on a dvd player if so what software can i use.
    i need to be able to do this to make it worth while for me to learn how to stream dvd's using java.
    thank you for your time.

    There is no supplied capability to do this, because the registry is Windows platform specific.
    It might be possible by making the call through a native Windoze app.

Maybe you are looking for

  • Yesterday, I recorded a voice memo on my iPhone 3G and accidentally deleted it. I have not synched the phone since recording it. Is there any way to retrieve it?

    Yesterday, I recorded a voice memo on my iPhone 3G and accidentally deleted it when trying to delete another message. The phone was not synched between recording it and accidentally deleting it. Is there anyway to recover the message?

  • Query regarding Date Function

    All, Can I know the difference between the following two queries select TO_CHAR(TRUNC(sysdate),'dd-mon-rr') from dual; select TO_CHAR(TRUNC(sysdate),'dd-mon-yy') from dual; However, both the query gives the same result as '03-nov-09'. Regards ND

  • Need help in solving error

    i am getting error as Redo sequence 9165 no longer available in online logs for thread 1 without ... without archiving enabled, SQL <SELECT MAX(sequence#) FROM v$log WHERE thread# = :ora_thread AND status ... 'CURRENT', 'ACTIVE')>, error retrieving r

  • Database Size Required for SOA

    I will be installing SOA Suite with OSB in Exalogic for testing. It is not for the production environment and very simple application will be used for testing. Database admin asked me what size database would be required but I did not find clear answ

  • HDD & iPod 'not ejected properly' when iMac wakes.

    Hello again folks. I have a strange issue with my iMac and USB connected peripherals. I have an Iomega Mac Companion HDD used for Time Machine backups and an iPod Nano (4th Gen) connected via USB (both directly to the iMac). A while back I noticed th