Using java 'classname' vs. appletviewer 'html-filename'

I have made an applet that I view with appletviewer but I want to use buffered writer in my applet to write to an html file on the server. That way the user can see the results of his/her selections from the applet by clicking on a link from the applet page. The problem is when I excute by typing java 'classname', the file writing mechanism works, but I can't start thr applet unless I type appletviewer 'html-filename'. I thought I had fixed the problem by making my main class extend the frame class and using show() and setVisible(true). When I did this the applet showed itself when I used javac 'classname'. But Then I couldn't load it to a web page unless it was extending the applet class. If somebody can help please e-mail me or reply with another post.
[email protected]

You are correct, you can not run a Java application in a browser, it must be an applet. I believe you are saying you are trying to write a file to the server from the applet. From the Applet you can not write to the server (machine). However if you have a Java application acting as a server, running on the server (machine), your applet can communicate (via sockets or RMI or whatever) with the Java application acting as a server and it can write to a file.

Similar Messages

  • Using java to interact with html.

    I want to create a program that goes to html pages and presses some buttons. where do I look?

    Hi duo,
    please try and use the code snippet i am pasting below.The code is accessing a page and then submitting a form on the page by making the url in the code itself.
    import java.io.*;
    import java.net.*;
    public class SubmitHTML
         public static void main(String[] args)
              System.out.println("*********** GOING TO ACCESS PAGE START ***********");
              SubmitHTML s1 = new SubmitHTML();
              s1.getHTMLPage();
              System.out.println("*********** GOING TO ACCESS PAGE END ***********");
         private void getHTMLPage()
              //phase 1
              try
                   String str = "";
                   char ch1=(char)0x0d; //\r
                   String strURL = "http://tahiti.oracle.com/pls/tahiti/tahiti.error_search";
                   URL url = new URL(strURL);
                   HttpURLConnection.setFollowRedirects(false);
                   HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
                   //urlConn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
                   urlConn.setDoInput(true);
                   //urlConn.setUseCaches(false);
                   System.out.println("LOGIN: Reading..." + urlConn.getHeaderField(0));
                   System.out.println("getContentEncoding ..." + urlConn.getContentEncoding());
                   System.out.println("getContent..." + urlConn.getContent());
                   System.out.println("getContentType..." + urlConn.getContentType());
                   BufferedReader br = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
                   String line;
                   boolean flag = false;
                   while((line=br.readLine())!=null) {
                        //System.out.println(line);
                        str = str + line + String.valueOf(ch1);
                   System.out.println("*********** THE FIRST PAGE RETURNED BY GOOGLE IS START ***********");
                   System.out.println(str);
                   System.out.println("*********** THE FIRST PAGE RETURNED BY GOOGLE IS END ***********");
                   String strQuery = "ORA-9989";
                   strURL = "http://tahiti.oracle.com/pls/tahiti/tahiti.error_search?search="+strQuery+"";
                   System.out.println("The url is ::" + str);     
                   url = new URL(strURL);
                   HttpURLConnection.setFollowRedirects(false);
                   urlConn = (HttpURLConnection)url.openConnection();
                   //urlConn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
                   urlConn.setDoInput(true);
                   //urlConn.setUseCaches(false);
                   br = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
                   str = "";
                   while((line=br.readLine())!=null) {
                        //System.out.println(line);
                        str = str + line + String.valueOf(ch1);
                   System.out.println("\n\n\n");
                   System.out.println("*********** THE PAGE RETURNED BY GOOGLE AFTER SUBMITTING START ***********");
                   System.out.println("LOGIN: Reading..." + urlConn.getHeaderField(0));
                   System.out.println("getContentEncoding ..." + urlConn.getContentEncoding());
                   System.out.println("getContent..." + urlConn.getContent());
                   System.out.println("getContentType..." + urlConn.getContentType());
                   System.out.println(str);
                   System.out.println("*********** THE PAGE RETURNED BY GOOGLE AFTER SUBMITTING END ***********");
              catch (Exception e)
    anjani

  • Is it possible to write an HTML editor using Java?

    I have this final year project (for my degree), where I need to use Java to write an HTML editor.
    It doesn't have to be fancy or anything, just need to be able to generate HTML files from the GUI frontend where text, images and tables will be created.
    I'm new to Java, and I'm having problem with it.
    Please help, I only need to know whether it's possible, and possible a little guideline on how to go about it, please?
    Terry

    http://www.hexidec.com/ekit.php

  • How to convert from xml file to html using java code

    How to convert from xml file to html file using java code

    Get yourself Apache Xalan or Saxon or some XSLT processor
    String styleSheet = "/YourXSLTStylesheet.xsl";
    String dataSource = "/YourXMLDocument.xml";
    InputStream stylesheetSource = TransformMe.class.getResourceAsStream(styleSheet);
    InputStream dataSourceStream = TransformMe.class.getResourceAsStream(dataSource);
    OutputStream transformedOut = new FileOutputStream("filename.html");
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new StreamSource(stylesheetSource));
    transformer.transform(new StreamSource(dataSourceStream), new StreamResult(transformedOut));You'll also need to learn XSLT if you don't already know that. Here's a good place to start
    http://www.w3schools.com/xsl/

  • Changing HTML to text file using java

    Hi,
    I am doing a project in which i have to read news articles from websites. I have tried XML but for that i need to know which tag has the article in it. Since i have to read from various websites so each site used different tags for different informations.
    Is there anyway that i can change an HTML file into a text file using java. Maybe some command that removes all the HTML tags and gives just the information. Is there anything else that anyone would like to recommend?
    Thanx
    yafis

    Maybe something like this:
    import java.io.*;
    import java.net.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    class GetHTMLText
         public static void main(String[] args)
              throws Exception
              EditorKit kit = new HTMLEditorKit();
              Document doc = kit.createDefaultDocument();
              // The Document class does not yet handle charset's properly.
              doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
              // Create a reader on the HTML content.
              Reader rd = getReader(args[0]);
              // Parse the HTML.
              kit.read(rd, doc, 0);
              //  The HTML text is now stored in the document
              System.out.println( doc.getText(0, doc.getLength()) );
         // Returns a reader on the HTML data. If 'uri' begins
         // with "http:", it's treated as a URL; otherwise,
         // it's assumed to be a local filename.
         static Reader getReader(String uri)
              throws IOException
              // Retrieve from Internet.
              if (uri.startsWith("http:"))
                   URLConnection conn = new URL(uri).openConnection();
                   return new InputStreamReader(conn.getInputStream());
              // Retrieve from file.
              else
                   return new FileReader(uri);
    }

  • Help needed  while exporting crystal reports to HTML file format using java

    Help needed  while exporting crystal reports to HTML file format using java api(not using crystalviewer).i want to download the
    html file of the report
    thanks

    the ReportExportFormat class does not have HTML format, it has got to be XML. Export to HTML is available from CR Designer only.
    Edited by: Aasavari Bhave on Jan 24, 2012 11:37 AM

  • 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

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • How to create hyperlink in Html page using Java

    Hello every one
    I want to know that how can I create a hyperlink in Html page using java ?
    Let for example
    I have code like this and i want to give hyperlink to it using java.
    rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
    <tr>
    <td ><span id="name"></span>
    </tr>

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • How to send HTML Format Mail using Java Mail in oracle 9i Forms

    Dear All
    could you please tell me how to send HTML Format Mail using Java Mail in oracle 9i Forms and how to implement the java mail ?
    if it is possible, could you please send me the sample code? please very urgent
    Thanks
    P.Sivaraman

    Hello,
    <p>Here is a Form sample.</p>
    Francois

  • Access database using Java from HTML webpage

    Hi,
    I've got to create some online maths tests to be taken by students with their marks being stored in a database.
    I've wrote some simple java code which can add/remove and modify entries in a test mySQL database that I made. What I now need to do is be able to add entries to the database from a html page.
    The math tests will be java applets with the students having to interact according to questions, press submit and their score will be output. The score will then be entered into the database.
    The problem I'm having is that with an Applet their are all sorts of security issues (I'm having problems getting images to load in an Applet) so assume I'll face the same security issues when I try to access a database through an applet.
    So, could someone please help get started.
    Cheers

    MVC - I assume you mean model-view-control and not Marvel vs Capcom :)
    If so then does this mean I should completely seperate the user interface (the actual applets that will contain the test), the database (that will store the results) and the link between the two?
    is it possible to acheive this using Java, Java Applets, Java Script and the database (in my case mySQL) and could you give me some tips on how best to tackle the problem.
    Thanks

  • Interchage html table using java

    hey all ,
    how can i interchange the row and column of the table which is written inside a HTML file using Java ?
    like if i have html input file like :
    <HTML>
    <BODY>
    <table border="1">
    <tr>
    <th>NAME</th>
    <th>MONDAY</th>
    <th>TUESDAY</th>
    <th>WEDNESDAY</th>
    </tr>
    <tr>
    <td>A</td>
    <td>C++</td>
    <td>C</td>
    <td>Java</td>
    </tr>
    <tr>
    <td>B</td>
    <td>C</td>
    <td>C++</td>
    <td>Java</td>
    </tr>
    <tr>
    <td>C</td>
    <td>Java</td>
    <td>C++</td>
    <td>C</td>
    </tr>
    </table>
    </BODY>
    </HTML> then my java program generate HTML output file like this :
    <HTML>
    <BODY>
    <table border="1">
    <tr>
    <th>NAME</th>
    <th>A</th>
    <th>B</th>
    <th>C</th>
    </tr>
    <tr>
    <td>MONDAY</td>
    <td>C++</td>
    <td>C</td>
    <td>Java</td>
    </tr>
    <tr>
    <td>TUESDAY</td>
    <td>C</td>
    <td>C++</td>
    <td>C++</td>
    </tr>
    <tr>
    <td>WEDNESDAY</td>
    <td>Java</td>
    <td>Java</td>
    <td>C</td>
    </tr>
    </table>
    </BODY>
    </HTML>

    hi all ,
    check out this code wiz , but it will not work when when the 2d string array is not square matrix ...any suggestions to remove this limitation ?
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.*;
    public class ParseHTML
         public static void main(String[] args)
              String a[][]=new String[10][10];
              String fName = "test.html"; //input file name
              a=htmlread(fName);
              String b[][]=new String [10][10];
              b=transpose(a);
              htmlwrite(b,fName);
         public static String[][] htmlread(String fName) //this method will read the file and returns a matrix
              String thisLine;
                  String temp[][]=new String[10][10];
                  try
                  FileInputStream fis = new FileInputStream(fName);
                  DataInputStream myInput = new DataInputStream(fis);
                  int i=-1;
                  int j=-1;
                  while ((thisLine = myInput.readLine()) != null)
                   if(thisLine.trim().startsWith("<tr>"))
                        i++;
                        j=-1;
                   if(thisLine.trim().startsWith("<td>"))
                        j++;
                        thisLine=thisLine.replace("<td>","");
                        thisLine=thisLine.replace("</td>","");
                        temp[i][j]=thisLine;
            catch(IOException e)
                   e.printStackTrace();
                   System.out.println("File Not Found");
            return temp;
        public static String[][] transpose(String a[][]) //this method will return a tranpose matrix
             String b[][]=new String[a[0].length][a.length];
             for(int i=0;i<a[0].length;i++)
                  for(int j=0;j<a.length;j++)
                       b[i][j]=a[j];
         return b;
    public static void htmlwrite(String b[][],String fName)
    FileOutputStream fout;
    int i=-1;
    int j=-1;
    int flag=0;     
                   // Open an output stream
              try
              fout = new FileOutputStream ("myfile1.html");     
                   FileInputStream fis = new FileInputStream(fName);
              DataInputStream myInput = new DataInputStream(fis);
              String thisLine;
              while ((thisLine = myInput.readLine()) != null)
                   if(thisLine.trim().startsWith("<tr>"))
                        i++;
                        flag=0;
                   if(thisLine.trim().startsWith("<td>"))
                        j++;
                        if(flag==0)
                             j=0;
                             flag=1;
                        thisLine="<td>"+b[i][j]+"</td>";
                        System.out.println(i+" "+j);
              // Print a line of text
              new PrintStream(fout).println (thisLine);
              // Close our output stream
              fout.close();
              catch (IOException e)
                   System.err.println ("Unable to write to file");
                   System.exit(-1);

  • Using java mail api without servlets, I ve sent an html mail.  In that Ive

    Using java mail api without servlets, I ve sent an html mail. In that Ive specified action to the servlet. On click, it shows url as file:///C:/Documents%20and%20Settings/sirivanig/Local%20Settings/Temporary%20Internet%20Files/Content.IE5/CNFHMDIT/updatemailerform%5B2%5D.htm instead of www.servername.com/....
    May I know the reason why it shows like this.
    Do I ve to send htmlmail through servlet so that it does show proper url?

    Possibly your mailer is restricting your access to URLs to prevent
    various scams. Without the details, it's hard to know what's going
    wrong.
    Have you tried with a different mailer?

  • Read values on HTML page(flash embedded) using Java code

    Hi,
    we can normally parse a HTML and can get values on a web page using java code.
    is the same possible with HTML page indluding flash?
    my basic need is to read values on webpage displayed by flash
    thanks
    R

    flash can communicate with javascript using the externalinterface class.

  • Edit HTML File using java

    Hi....
    I have a report in HTML format and a list of thresholds in txt format.
    Now, using java how can I:
    1. Compare the values in the report with the thresholds
    2. Edit the report such that values over the thresholds are highlighted in say, red colour.
    I am new to Java programming, so java jargons won't be of much help. I read about jeditorpane but it's primary use is to display html file(that is what i inferred). Is their a way in which i could accomplish the above using jeditorpane??....how do i do the comparison part??

    srgsoroka wrote:
    Did you check http://jtidy.sourceforge.net/.
    From site:
    "JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the document that is being processed, which effectively makes you able to use JTidy as a DOM parser for real-world HTML."Yes, I did. But I don't need a syntax checker.The syntax is alright. I want to modify the HTML code after comparison with a txt document.As far as DOM parser is concerned, I googled the term but didn't understand much of it..:-(...If you could explain it in layman's terms........

Maybe you are looking for

  • Page zoom not holding between pages in FF4

    Back in good old FF 3 page zoom would hold between pages or on refresh, I am finding with FF4 every time I reload a page or click a link to a different part of the same website I need to re-size the page, as I use FF for its zoom function this is sta

  • Behaviour of a trigger during a blocking lock

    Post deleted Edited by: user10656925 on Nov 30, 2008 10:03 PM

  • Can I disable Fill & Sign toolbar?

    The latest 11.0.09 release of Reader by default opens the Fill & Sign toolbar on any PDF with fillable forms.  My web application makes heavy use of embedded PDFs and fillable forms, but I do not want the toolbar to appear.  I cannot seem to find any

  • Master-Detail table on the JSF is unable to update the database

    Hi all, In my ADF application I am using a master-deatail relationship datasource. I have to enter the detail rows for a master table row and submit the detail rows it should update the database. For this I created a master-detail table and dragged t

  • Syntax to declare a variable in native sql

    Hi Experts, Please let me know the syntax to  declare a variable in Native SQL. Vivek Gupta