<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Threadbare Canvas Productions &#187; Java Web</title>
	<atom:link href="http://threadbarecanvas.com/category/java-web/feed/" rel="self" type="application/rss+xml" />
	<link>http://threadbarecanvas.com</link>
	<description>Online Journal of James Hogan the Web Developer</description>
	<lastBuildDate>Sun, 01 Aug 2010 19:32:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>English Stop Words &#8211; Semantic Text Search</title>
		<link>http://threadbarecanvas.com/java-web/english-stop-words-semantic-text-search/</link>
		<comments>http://threadbarecanvas.com/java-web/english-stop-words-semantic-text-search/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 19:32:43 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=176</guid>
		<description><![CDATA[Weather your analyzing your blog comments or looking at a single sentence one of the best way to discover the meaning of a peice of text is to perform text stemming and stop word removal to be left with the bones of the text. This post is a list of those words in an array [...]]]></description>
			<content:encoded><![CDATA[<p>Weather your analyzing your blog comments or looking at a single sentence one of the best way to discover the meaning of a peice of text is to perform text stemming and stop word removal to be left with the bones of the text. This post is a list of those words in an array string format. yay.</p>
<pre class="brush:javascript">
["a","able","about","above","abst","accordance","according","accordingly","across","act","actually",
"added","adj","adopted","affected","affecting","affects","after","afterwards","again","against","ah","all",
"almost","alone","along","already","also","although","always","am","among","amongst","an","and","announce",
"another","any","anybody","anyhow","anymore","anyone","anything","anyway","anyways","anywhere",
"apparently","approximately","are","aren","arent","arise","around","as","aside","ask","asking","at","auth",
"available","away","awfully","b","back","be","became","because","become","becomes","becoming","been",
"before","beforehand","begin","beginning","beginnings","begins","behind","being","believe","below","beside",
"besides","between","beyond","biol","both","brief","briefly","but","by","c","ca","came","can","cannot","can't",
"cause","causes","certain","certainly","co","com","come","comes","contain","containing","contains","could",
"couldnt","d","date","did","didn't","different","do","does","doesn't","doing","done","don't","down","downwards",
"due","during","e","each","ed","edu","effect","eg","eight","eighty","either","else","elsewhere","end","ending",
"enough","especially","et","et-al","etc","even","ever","every","everybody","everyone","everything","everywhere","ex","except","f",
"far","few","ff","fifth","first","five","fix","followed","following","follows","for","former","formerly","forth","found",
"four","from","further","furthermore","g","gave","get","gets","getting","give","given","gives","giving","go","goes",
"gone","got","gotten","h","had","happens","hardly","has","hasn't","have","haven't","having","he","hed","hence",
"her","here","hereafter","hereby","herein","heres","hereupon","hers","herself","hes","hi","hid","him","himself","his",
"hither","home","how","howbeit","however","hundred","i","id","ie","if","i'll","im","immediate","immediately",
"importance","important","in","inc","indeed","index","information","instead","into","invention","inward","is","isn't",
"it","itd","it'll","its","itself","i've","j","just","k","keep","        keeps","kept","keys","kg","km","know","known","knows","l","largely","last","lately","later","latter","latterly",
"least","less","lest","let","lets","like","liked","likely","line","little","'ll","look","looking","looks","ltd","m","made",
"mainly","make","makes","many","may","maybe","me","mean","means","meantime","meanwhile","merely","mg",
"might","million","miss","ml","more","moreover","most","mostly","mr","mrs","much","mug","must","my","myself","n",
"na","name","namely","nay","nd","near","nearly","necessarily","necessary","need","needs","neither","never",
"nevertheless","new","next","nine","ninety","no","nobody","non","none","nonetheless","noone","nor","normally",
"nos","not","noted","nothing","now","nowhere","o","obtain","obtained","obviously","of","off","often","oh","ok",
"okay","old","omitted","on","once","one","ones","only","onto","or","ord","other","others","otherwise","ought",
"our","ours","ourselves","out","outside","over","overall","owing","own","p","page","pages","part","particular",
"particularly","past","per","perhaps","placed","please","plus","poorly","possible","possibly","potentially","pp",
"predominantly","present","previously","primarily","probably","promptly","proud","provides","put","q","que",
"quickly","quite","qv","r","ran","rather","rd","re","readily","really","recent","recently","ref","refs","regarding",
"regardless","regards","related","relatively","research","respectively","resulted","resulting","results","right","run",
"s","said","same","saw","say","saying","says","sec","section","see","seeing","seem","seemed","seeming","seems",
"seen","self","selves","sent","seven","several","shall","she","shed","she'll","shes","should","shouldn't","show",
"showed","shown","showns","shows","significant","significantly","similar","similarly","since","six","slightly","so",
"some","somebody","somehow","someone","somethan","something","sometime","sometimes","somewhat",
"somewhere","soon","sorry","specifically","specified","specify","specifying","state","states","still","stop",
"strongly","sub","substantially","successfully","such","sufficiently","suggest","sup","sure","        t","take","taken","taking","tell","tends","th","than","thank","thanks","thanx","that","that'll","thats","that've",
"the","their","theirs","them","themselves","then","thence","there","thereafter","thereby","thered","therefore",
"therein","there'll","thereof","therere","theres","thereto","thereupon","there've","these","they","theyd","they'll",
"theyre","they've","think","this","those","thou","though","thoughh","thousand","throug","through","throughout",
"thru","thus","til","tip","to","together","too","took","toward","towards","tried","tries","truly","try","trying","ts",
"twice","two","u","un","under","unfortunately","unless","unlike","unlikely","until","unto","up","upon","ups","us",
"use","used","useful","usefully","usefulness","uses","using","usually","v","value","various","'ve","very","via","viz",
"vol","vols","vs","w","want","wants","was","wasn't","way","we","wed","welcome","we'll","went","were","weren't",
"we've","what","whatever","what'll","whats","when","whence","whenever","where","whereafter","whereas",
"whereby","wherein","wheres","whereupon","wherever","whether","which","while","whim","whither","who",
"whod","whoever","whole","who'll","whom","whomever","whos","whose","why","widely","willing","wish","with",
"within","without","won't","words","world","would","wouldn't","www","x","y","yes","yet","you","youd","you'll",
"your","youre","yours","yourself","yourselves","you've","z","zero"]
</pre>
<p>The following is the simpe program that i used to convert a text file of these Stop words into the array string above.</p>
<pre class="brush:java">
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package arrayify;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Siriquelle
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        try
        {
            BufferedReader in = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("StopWords.txt")));
            String str = "";
            StringBuilder sb = new StringBuilder();
            while ((str = in.readLine()) != null)
            {
                sb.append("\"").append(str).append("\"");
            }
            str = sb.toString().replaceAll("\"\"", "\",\"");
            System.out.print(str);
            in.close();
        } catch (IOException e)
        {
            System.out.print(e.toString());
        }
    }
}
</pre>
<p>Hope this saves you some time. Many thanks to &lt;a href=&#8221;http://www.ranks.nl/resources/stopwords.html&#8221; &gt;http://www.ranks.nl/resources/stopwords.html &lt;/a&gt; for the list of words.</p>
<p><map name='google_ad_map_176_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/176?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_176_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=176&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Fenglish-stop-words-semantic-text-search%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/english-stop-words-semantic-text-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Way Tweet a Java App</title>
		<link>http://threadbarecanvas.com/java/one-way-tweet-a-java-app/</link>
		<comments>http://threadbarecanvas.com/java/one-way-tweet-a-java-app/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 09:33:31 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=115</guid>
		<description><![CDATA[One way tweet is a sending application for twitter. In this tutorial you will see/learn how to send stuff to twitter by writing a java desktop UI. You will create a new project in NetBeans and choose java application, and create a new package called org.me.owt. 
Then, create a new java source file and call it [...]]]></description>
			<content:encoded><![CDATA[<p>One way tweet is a sending application for twitter. In this tutorial you will see/learn how to send stuff to twitter by writing a java desktop UI. You will create a new project in NetBeans and choose java application, and create a new package called org.me.owt. </p>
<p>Then, create a new java source file and call it main.java, and another called tweet.java. Two simple classes and you&#8217;ve got yourself a twitter client. The end result will look like this:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/owt.png"><img src="http://threadbarecanvas.com/wp-content/uploads/2009/07/owt.png" alt="One Way Tweet" title="One Way Tweet" width="309" height="312" class="aligncenter size-full wp-image-116" /></a></p>
<pre class="brush:java">
/*
 * Main.java
 *
 * Created on 23-Jul-2009, 11:57:04
 */
package org.me.owt;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Siriquelle
 */
public class Main extends javax.swing.JFrame {

    private JButton button;

    /** Creates new form Main*/
    public Main() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        usernamelabel = new java.awt.Label();
        username = new java.awt.TextField();
        passwordlabel = new java.awt.Label();
        password = new java.awt.TextField();
        status = new java.awt.TextArea();
        tweet = new java.awt.Button();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("One Way Tweet");
        setBackground(new java.awt.Color(204, 255, 255));
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setForeground(new java.awt.Color(204, 255, 255));
        setName("One Way Tweet"); // NOI18N
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(204, 255, 255));
        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setAlignmentX(getWidth() / 2);
        jPanel1.setAlignmentY(getHeight() / 2);

        usernamelabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        usernamelabel.setForeground(new java.awt.Color(0, 102, 102));
        usernamelabel.setName("usernameLabel"); // NOI18N
        usernamelabel.setText("Username");

        username.setForeground(new java.awt.Color(51, 51, 51));
        username.setName("username"); // NOI18N
        username.addFocusListener(new java.awt.event.FocusAdapter() {

            public void focusGained(java.awt.event.FocusEvent evt) {
                Main.this.focusGained(evt);
            }

            public void focusLost(java.awt.event.FocusEvent evt) {
                Main.this.focusLost(evt);
            }
        });

        passwordlabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        passwordlabel.setForeground(new java.awt.Color(0, 102, 102));
        passwordlabel.setName("passwordLabel"); // NOI18N
        passwordlabel.setText("Password");

        password.setEchoChar('*');
        password.setForeground(new java.awt.Color(51, 51, 51));
        password.setName("password"); // NOI18N
        password.addFocusListener(new java.awt.event.FocusAdapter() {

            public void focusGained(java.awt.event.FocusEvent evt) {
                Main.this.focusGained(evt);
            }

            public void focusLost(java.awt.event.FocusEvent evt) {
                Main.this.focusLost(evt);
            }
        });

        status.setForeground(new java.awt.Color(51, 51, 51));
        status.setName("status"); // NOI18N
        status.addFocusListener(new java.awt.event.FocusAdapter() {

            @Override
            public void focusGained(java.awt.event.FocusEvent evt) {
                Main.this.focusGained(evt);
            }

            @Override
            public void focusLost(java.awt.event.FocusEvent evt) {
                Main.this.focusLost(evt);
            }
        });

        tweet.setActionCommand("tweet");
        tweet.setBackground(new java.awt.Color(153, 255, 255));
        tweet.setFont(new java.awt.Font("Impact", 1, 48)); // NOI18N
        tweet.setForeground(new java.awt.Color(0, 102, 102));
        tweet.setLabel("tweet");
        tweet.setName("tweet"); // NOI18N
        tweet.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tweetMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE).addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(passwordlabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(usernamelabel, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))).addComponent(tweet, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap()));
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(usernamelabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(passwordlabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(tweet, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap()));

        usernamelabel.getAccessibleContext().setAccessibleName("usernameLabel");
        username.getAccessibleContext().setAccessibleName("username");
        password.getAccessibleContext().setAccessibleName("password");
        status.getAccessibleContext().setAccessibleName("status");
        tweet.getAccessibleContext().setAccessibleName("tweet");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE));

        getAccessibleContext().setAccessibleName("One Way Tweet");
        getAccessibleContext().setAccessibleDescription("One Way Tweet");

        pack();
    }// </editor-fold>

    private void tweetMouseClicked(java.awt.event.MouseEvent evt) {
        Tweet tw = new Tweet(username.getText(), password.getText(), status.getText());
        if (tw.sendTweet())
        {
            this.ShowMessageDialog("Tweet Win");
        } else
        {
            this.ShowMessageDialog("Tweet Fail");
        }
    }

    private void focusGained(java.awt.event.FocusEvent evt) {
        evt.getComponent().setBackground(new java.awt.Color(255, 255, 215));
    }

    private void focusLost(java.awt.event.FocusEvent evt) {
        evt.getComponent().setBackground(new java.awt.Color(255, 255, 255));
    }

    public void ShowMessageDialog(String msg) {
        final JFrame frame = new JFrame(msg);
        button = new JButton("OK");
        button.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                frame.dispose();
            }
        });

        JPanel panel = new JPanel();
        panel.add(button);
        panel.add(button);
        frame.add(panel);
        frame.setSize(220, 80);
        frame.setLocation(220, 80);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JPanel jPanel1;
    private java.awt.TextField password;
    private java.awt.Label passwordlabel;
    private java.awt.TextArea status;
    private java.awt.Button tweet;
    private java.awt.TextField username;
    private java.awt.Label usernamelabel;
    // End of variables declaration
}
</pre>
<p>The following code is a class that handles the tweet. create a new java source file in the org.me.owt package and call it tweet.java. It&#8217;s methods are used to create and send the tweet and handle the response from the twitter api:</p>
<pre class="brush:java">
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.owt;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

/**
 *
 * @author Siriquelle
 */
public class Tweet {

    private String twitteruser;
    private String twitterpass;
    private String status;
    private String response;

    public Tweet(String u, String p, String s) {
        twitteruser = u;
        twitterpass = p;
        status = s;
    }

    public boolean sendTweet() {
        try
        {
            String encodedData = URLEncoder.encode(status, "UTF-8");

            String credentials = twitteruser + ":" + twitterpass;
            String encodecredentials = new sun.misc.BASE64Encoder().encode(credentials.getBytes());

            URLConnection connection = null;
            URL url = new URL("http://twitter.com/statuses/update.xml");
            connection = url.openConnection();
            connection.setRequestProperty("Authorization", "Basic " + encodecredentials);
            connection.setDoOutput(true);

            OutputStreamWriter output = new OutputStreamWriter(connection.getOutputStream());
            output.write("status=" + encodedData);
            output.close();

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String decodedString;
            while ((decodedString = in.readLine()) != null)
            {
                response = decodedString;
            }
            in.close();
            return true;
        } catch (Exception e)
        {
            response = e.toString();
            return false;
        }
    }
}
</pre>
<p>And thats the code, right click your project and choose run. After you examine this code you&#8217;ll discover how, with a little parsing you can turn this application into a fully fledged thwirl competitor. :) If you&#8217;ve any questions I&#8217;d love a go at answering.</p>
<p>This application was created in netbeans using the swing UI builder. In a future post I will describe the process to building an application using the NetBeans IDE and it&#8217;s UI builders in design view.</p>
<p><map name='google_ad_map_115_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/115?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_115_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=115&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava%2Fone-way-tweet-a-java-app%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java/one-way-tweet-a-java-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Universal Translator for your Tweets</title>
		<link>http://threadbarecanvas.com/java-web/universal-translator-for-your-tweets/</link>
		<comments>http://threadbarecanvas.com/java-web/universal-translator-for-your-tweets/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 10:21:19 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[google translate]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=98</guid>
		<description><![CDATA[I thought this was going to be easy&#8230; SO much for preconceptions. Today, I&#8217;m going to give you the code to create a twitter translation App using, HTML, CSS, JavaScript and Java, the Twitter API and the Google Translate API. In a future tutorial I will demonstrate cross domain Ajax to get this Application to [...]]]></description>
			<content:encoded><![CDATA[<p>I thought this was going to be easy&#8230; SO much for preconceptions. Today, I&#8217;m going to give you the code to create a twitter translation App using, HTML, CSS, JavaScript and Java, the Twitter API and the Google Translate API. In a future tutorial I will demonstrate cross domain Ajax to get this Application to work totally on the client side but in the mean time you will need to have a Java enabled server to execute the server-side <abbr title="Java Server Page">JSP</abbr> that requests the API for twitter.</p>
<p>As you type your tweet the the JavaScript will analyze your keystrokes and check for when a space is entered assuming you are done typing a word, at this point the text is passed to Google for translation. When your done typing hit tweet and it&#8217;s off to twitter with your tweet.</p>
<p>This is what your app will look like when it&#8217;s finished:</p>
<p><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/translateApp.png"><img class="aligncenter size-full wp-image-99" title="translateApp" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/translateApp.png" alt="translateApp" width="399" height="395" /></a></p>
<p style="text-align: center; font-size: 24px;"><strong><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/twitterLang.zip" target="_blank">Source</a><br />
</strong></p>
<p>The Folder structure you will need is similar to all other projects. You can download the source folder for this project and open it in NetBeans to get a better idea of how the end result will look. There are no special libraries you need to get this going just java.io.* and java.net.* .</p>
<p>This is the HTML you will need, (/index.html):</p>
<pre class="brush:html">&lt;!DOCTYPE html&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;link rel="Stylesheet" media="screen" href="assets/css/style.css" &gt;
        &lt;title&gt;Twitter Universal Translate&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="content"&gt;
            &lt;div class="head"&gt;Twitter Multilanguage&lt;/div&gt;

            &lt;form&gt;
                &lt;label class="textlabel" for="username"&gt;Username&lt;/label&gt;
                &lt;input class="textinput" type="text" id="username" name="username" value=""&gt;

                &lt;label class="textlabel" for="password"&gt;Password&lt;/label&gt;
                &lt;input class="textinput" type="password" id="password" name="password" value=""&gt;

                &lt;label class="textlabel" for="lang"&gt;Translate To&lt;/label&gt;
                &lt;select class="select" id="lang" name="lang" onclick="translateTwo()" &gt;
                    &lt;option value="en"&gt;English&lt;/option&gt;
                    &lt;option value="fr"&gt;French&lt;/option&gt;
                    &lt;option value="it"&gt;Italian&lt;/option&gt;
                    &lt;option value="de"&gt;German&lt;/option&gt;
                &lt;/select&gt;

                &lt;label class="textlabel" for="textarea"&gt;Tweet&lt;/label&gt;
                &lt;textarea id="textarea" class="textarea" name="textarea" cols="5" rows="5" onblur="translateTwo()" onkeydown="translate(event)"&gt;&lt;/textarea&gt;

                &lt;input class="textinput" type="button" value="Tweet" onclick="callLoad()"/&gt;
            &lt;/form&gt;
            &lt;div class="infobar"&gt;“Translate your tweet into a chosen language as you type.”&lt;/div&gt;
            &lt;span id="status"&gt;&lt;/span&gt;
        &lt;/div&gt;

        &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="assets/js/jscript.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>This is the CSS you will need, (/assets/css/style.css):</p>
<pre class="brush:css">* {
    margin: 0;
    padding: 0;
}

/*///////////////////////////////////////////////////*/

#content{
    color:#333;
    width:350px;
    margin:100px auto;
    border:15px inset #66ffff;
    padding:10px;
    font-family:sans-serif;
    -moz-border-radius:10px;
}

.textlabel,textinput{
    display:block;
}

.textlabel{
    font-weight:bold;
}

.textlabel,.textinput, .textarea,.select{
    width:200px;
}

.textinput, .textarea,.select{
    padding:1px;
    margin-bottom:5px;
}

.textinput:focus, .textarea:focus{
    background-color:#ffffcc;
}

.head{
    font-size:32px;
    font-family:sans-serif;
    font-weight:bold;
    margin-bottom:5px;
}

.infobar{
    width:120px;
    float:right;
    position:relative;
    top:-140px;
    left:0px;
    padding: 3px;
    border:5px #ffff99 solid;
    background-color:#ffffcc;
    color:#003333;
    font-size:14px;
    font-style:oblique;
    text-align:center;
}</pre>
<p>This is the JavaScript you will need, (/assets/js/jscript.js):</p>
<pre class="brush:jscript">google.load("language", "1");

function translate(event){
    var textarea = document.getElementById("textarea");
    var lang = document.getElementById("lang");

    if(event.keyCode == 32){
        google.language.translate(textarea.value, "", lang.value, function(result) {
            if (!result.error) {
                var container = document.getElementById("textarea");
                container.value = result.translation + " ";
            }
        });
    }
}

function translateTwo(){
    var textarea = document.getElementById("textarea");
    var lang = document.getElementById("lang");
    google.language.translate(textarea.value, "", lang.value, function(result) {
        if (!result.error) {
            var container = document.getElementById("textarea");
            container.value = result.translation + " ";
        }
    });
}

function load(url, callback) {
    var xhr = new XMLHttpRequest();

    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;
    var status = document.getElementById("textarea").value;
    var auth = "tweet.jsp?username="+username+"&amp;password="+password+"&amp;status="+status;

    xhr.onreadystatechange = function() {
        if((xhr.readyState &lt; 4) || xhr.status !== 200) return;
        callback(xhr);
    };
    try{
        xhr.open('GET', auth, true);
        xhr.send();
    }catch(e){
        document.write(e);
    }
}

function callLoad(){
    load('tweet.jsp', function(xhr) {
        var joke = document.getElementById("status");
        var textarea = document.getElementById("textarea");
        joke.innerHTML = '<strong>OK</strong>';
        textarea.value = '';
    });
}</pre>
<p>This is the Java you will need, (/tweet.jsp):</p>
<pre class="brush:java">&lt;%@page import="java.net.*, java.io.*"%&gt;
&lt;%
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String status = request.getParameter("status");
        try {
            String twitteruser = username;
            String twitterpass = password;
            String encodedData = URLEncoder.encode(status, "UTF-8");

            String credentials = twitteruser + ":" + twitterpass;
            String encodecredentials = new sun.misc.BASE64Encoder().encode(credentials.getBytes());

            URLConnection connection = null;
            URL url = new URL("http://twitter.com/statuses/update.xml");
            connection = url.openConnection();
            connection.setRequestProperty("Authorization", "Basic " + encodecredentials);
            connection.setDoOutput(true);

            OutputStreamWriter output = new OutputStreamWriter(connection.getOutputStream());
            output.write("status=" + encodedData);
            output.close();

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String decodedString;
            while ((decodedString = in.readLine()) != null) {
                out.println(decodedString);
            }
            in.close();

        } catch (Exception e) {
            System.out.println(e.toString());
        }

%&gt;</pre>
<p>Ideally a Servlet would be best suited to processing the response from twitter but for this project it&#8217;s OK. And there you go you can now tweet in multiple languages like James Bond might. yay!</p>
<p><map name='google_ad_map_98_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/98?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_98_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=98&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Funiversal-translator-for-your-tweets%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/universal-translator-for-your-tweets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a JavaWeb Email Contact Form</title>
		<link>http://threadbarecanvas.com/java-web/creating-a-javaweb-email-contact-form/</link>
		<comments>http://threadbarecanvas.com/java-web/creating-a-javaweb-email-contact-form/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 22:29:06 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javaMail]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=82</guid>
		<description><![CDATA[In a previous tutorial I have explained how to create a new NetBeans project and add a library to it to make the classes that are available in a jar available to use in your own project. If you are unsure how to do this go ahead and check out this article.
In this tutorial I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous tutorial I have explained how to create a new NetBeans project and add a library to it to make the classes that are available in a <abbr title="Java Archive file">jar</abbr> available to use in your own project. If you are unsure how to do this go ahead and check out <a href="http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/">this article</a>.</p>
<p style="text-align: left;">In this tutorial I&#8217;m going to explain how to create a contact form with a jQuery validation template for you to play with that will send an email to whomever. The end result should look like this:</p>
<p style="text-align: center;"><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/form.png"><img class="size-full wp-image-85 aligncenter" title="form" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/form.png" alt="form" width="503" height="397" /></a></p>
<p style="text-align: center; font-size: 24px;"><strong><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/Contactform.zip" target="_blank">Source</a><br />
</strong></p>
<p>Your going to need some form of access to an smtp mailbox with a username and password. You can use your gmail account info if you like, all your going to need is your gmail address and password.<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/gmail.png"><img class="alignnone size-full wp-image-86" title="gmail" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/gmail.png" alt="gmail" width="551" height="167" /></a></p>
<p>Now for the fun part, First of all you need to set up a new web application project in netBeans I&#8217;ve called mine ContactForm. In the index.jsp file in the root of your directory you should past this html structure. It&#8217;s going to set up the form. Simple elegant yet expandable if you want. You&#8217;ll see how easy it is to build custom emails with this form by adding new fields and manipulating a variable or two near the end of this tutorial.</p>
<pre class="brush:html">&lt;%@page import="mail.SendEmail" %&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" &gt;
        &lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css"&gt;
        &lt;link href="assets/css/style.css" rel="stylesheet" type="text/css" media="screen" &gt;
        &lt;title&gt;Multilingual Contact Form&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="container"&gt;
            &lt;p class="heading"&gt;Contact Form&lt;/p&gt;
            &lt;form action="index.jsp" method="POST"&gt;
                &lt;div class="input"&gt;
                    &lt;label for="fullname"&gt;Name:&lt;/label&gt;
                    &lt;input type="text" id="fullname" name="fullname" value="" /&gt;
                    &lt;div id="fullname_warn" &gt;&lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="input"&gt;
                    &lt;label for="email" &gt;Email:&lt;/label&gt;
                    &lt;input type="text" id="email" name="email" value="" /&gt;
                    &lt;span id="email_warn" &gt;&lt;/span&gt;
                &lt;/div&gt;

                &lt;div class="input"&gt;
                    &lt;label for="message" &gt;Message:&lt;/label&gt;
                    &lt;textarea cols="10" rows="5" id="message" name="message"&gt;&lt;/textarea&gt;
                &lt;/div&gt;

                &lt;input type="submit" name="send" value="send" id="send" /&gt;
            &lt;/form&gt;

            &lt;%
        if (request.getParameter("fullname") != null) {
            String fullname = request.getParameter("fullname");
            String email = request.getParameter("email");
            String message = request.getParameter("message");

            if (mail.SendEmail.run(email, fullname, message)) {
            %&gt;
            &lt;p class="goodtogo end"&gt;Mail Sent Successfully&lt;/p&gt;
            &lt;%} else {%&gt;
            &lt;p class="warning end"&gt;Error Sending Mail&lt;/p&gt;
            &lt;%}
        }
            %&gt;

        &lt;/div&gt;
        &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="assets/js/jscript.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Now that the html structure is in place it&#8217;s time to transform it into something a little easier on the eye. We&#8217;re going to add some styles. Before you go ahead and do this you should go ahead and set up your folder structures. It&#8217;s imperative that you have your files arranged in an organized way so that other developers can easily find what their looking. That, and if you need to take pictures to remember a holiday then you should defiantly be making your documents easier to find. Your folder structure should look like this:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/folderstructure.png"><img class="alignnone size-full wp-image-87" title="folderstructure" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/folderstructure.png" alt="folderstructure" width="214" height="487" /></a></p>
<p>Now that youve got somewhere to put your styles you should go ahead and stick them in this folder. Here they are:</p>
<pre class="brush:css">div#container{
    max-width:578px;
    min-width:440px;
    border:1px solid #222;
    padding:20px;
    margin:100px auto;
    color:#222233;
    font-family:sans-serif;
    -moz-border-radius:20px;
}

p.heading{
    font-size:36px;
    font-weight:bold;
}

.input,#send{
    font-size:24px;
    margin-top:10px;
}

.input label{
    display:block;
    text-decoration:underline;
}

.input input, .input textarea{
    width:300px;
    padding:1px;
}

#send{
    font-size:16px;
    cursor:pointer;
    width:120px;
    height:50px;
}

.warning, .goodtogo{
    font-size:20px;
    padding-left:35px;
    width:225px;
    height:33px;
    float:right;
    clear:right;

}

.warning{
    background:transparent url(../img/warn.png) no-repeat -5px -33px scroll;
}

.goodtogo{
    background:transparent url(../img/warn.png) no-repeat 0px 0px scroll;
}

.end{
    position:relative;
    top:-40px;
}</pre>
<p>Now you need a sprite for your error icons. I&#8217;ve made this one you should stick it in the &#8216;img&#8217; folder your created under &#8216;assets&#8217; like the structure shown above.<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/warn.png"><img class="alignnone size-full wp-image-84" title="warn" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/warn.png" alt="warn" width="40" height="60" /></a></p>
<p>The following demonstrates dynamic class application with JQuery. You should play around with this fill and add validation to the form fields while getting familiar with the JQuery framework:</p>
<pre class="brush:jscript">$(document).ready(function() {

    var fullname = $('#fullname');
    var fullname_warn = $('#fullname_warn');

    var email = $('#email');
    var email_warn = $('#email_warn');

    fullname.focus(function(){
        fullname_warn.removeClass('goodtogo');
        fullname_warn.addClass('warning');
        fullname_warn.html("Cannot be blank");

        fullname.blur(function(){
            fullname_warn.removeClass('warning');
            fullname_warn.addClass('goodtogo');
            fullname_warn.html(" ");
        });
    });

    email.focus(function(){
        email_warn.removeClass('goodtogo');
        email_warn.addClass('warning');
        email_warn.html("Cannot be blank");

        email.blur(function(){
            email_warn.removeClass('warning');
            email_warn.addClass('goodtogo');
            email_warn.html(" ");
        });
    });

});</pre>
<p>Now that we have a base structure in place it&#8217;s time to start bringing in the JavaMail API into your project. Ive made it available to <a href="http://files.getdropbox.com/u/414996/mail.jar">download here</a> so you can just download it. Ok? Create a JavaMail library and add it to your project as in the<a href="http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/"> iText tutorial.</a></p>
<p>So the final step in this is easy&#8230; Create a new package called &#8216;mail&#8217; in your Source Packages roll out in your project folder structure as seen here:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/javaClassStructure.png"><img class="alignnone size-full wp-image-88" title="javaClassStructure" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/javaClassStructure.png" alt="javaClassStructure" width="214" height="55" /></a></p>
<p>As you can see from above a new Java Class file called SendMail has been added to the &#8216;mail&#8217; package, create that file now and add this code to it:</p>
<pre class="brush:java">package mail;

/**
 *
 * @author Siriquelle
 */
import java.util.Date;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 *
 * @author Siriquelle
 */
public class SendEmail {

    public static boolean run(String addressedTo, String subject, String content) {

        String fromAddress = "Your Name ";//Your Email Address//
        String recipients = addressedTo.trim();
        String contentType = "text/plain";

        String smtpHost = "smtp.gmail.com";//Your Outgoing Mailbox//
        int smtpPort = 587;
        String username = "you@gmail.com";//Your Mailbox Username//
        String password = "yourpassword";//Your Mailbox Password//

        try
        {
            Properties props = System.getProperties();
            props.put("mail.smtp.starttls.enable", "true");
            Session session = Session.getDefaultInstance(props);

            MimeMessage message = new MimeMessage(session);

            message.setFrom(new InternetAddress(fromAddress));
            message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(recipients, false));

            message.setSubject(subject);
            message.setContent(content, contentType);
            message.setSentDate(new Date());

            Transport transport = session.getTransport("smtp");
            transport.connect(smtpHost, smtpPort, username, password);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();

            return true;
        } catch (MessagingException messagingException)
        {
            System.out.print(messagingException);
            return false;

        } catch (Exception e)
        {
            System.out.print(e);
            return false;
        }
    }
}</pre>
<p>And that is it. You should now have a valid working form that will send emails. Nice. If you don&#8217;t check that your folder structure matches <a title="Folder Structure" href="http://threadbarecanvas.com/wp-content/uploads/2009/07/folderstructure.png" target="_blank">mine</a>. Check that you&#8217;ve added your own GMail username and password in the SendEmail java class.</p>
<p><map name='google_ad_map_82_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/82?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_82_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=82&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Fcreating-a-javaweb-email-contact-form%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/creating-a-javaweb-email-contact-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaFX Hello World</title>
		<link>http://threadbarecanvas.com/java-web/java-fx-hello-world/</link>
		<comments>http://threadbarecanvas.com/java-web/java-fx-hello-world/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 13:09:34 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=41</guid>
		<description><![CDATA[It&#8217;s fun to learn new languages and althrough I prefer Actionscript 3 I&#8217;m giving JavaFX a shot because it&#8217;s been developerd by sun the guys that brought us JAVA. Ive heard of the ten minute JavaFX tutorial. This will be like a three minute tutorial. This screenshot gives an idea of how simple this will [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s fun to learn new languages and althrough I prefer Actionscript 3 I&#8217;m giving JavaFX a shot because it&#8217;s been developerd by sun the guys that brought us JAVA. Ive heard of the ten minute JavaFX tutorial. This will be like a three minute tutorial. This screenshot gives an idea of how simple this will be:</p>
<p><img class="alignnone size-full wp-image-46" title="JavaFX Hello World" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/a.png" alt="JavaFX Hello World" width="283" height="117" /></p>
<p>See, it says &#8220;Hello World&#8221; in the viewport, and &#8220;Hello World&#8221; in the window frame. Bellow is the code that makes this happen.</p>
<pre class="brush:java">package HelloWorld;

/*Import all of the packages we'll be using. */
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;

/*The stage is the window. */
Stage {
    title: "Hello World"
    width: 250
    height: 80

/*The scene is the viewport. The stage has a variable named scene that is Scene object. */
    scene: Scene {

/* The scene has some content inside it, in this case is will be the "Hello World" text.*/
        content: [
/* When you're programming be prepared to think of everything. We need to program our text by giving it a size and a family*/
            Text {
                font : Font {
                    name: "Sans Serif"
                    size : 16
                }
/*Here is where we answer the question of where we want to place the text we've just created in the viewport in number of pixels*/
                x: 10
                y: 30
/*The content of our text box will be some text right.*/
                content: "Hello World"
            }/*end text*/
        ]/*end scene content*/
    }/*end scene*/
}/*end Stage*/</pre>
<p><map name='google_ad_map_41_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/41?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_41_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=41&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Fjava-fx-hello-world%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/java-fx-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Web &#8216;Hello World&#8217;</title>
		<link>http://threadbarecanvas.com/java-web/java-web-hello-world/</link>
		<comments>http://threadbarecanvas.com/java-web/java-web-hello-world/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 12:43:33 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=1</guid>
		<description><![CDATA[As a Web Developer I naturally enjoy web development and writing a blog has always been on my mind. I start and stop and start and well. You get the message. I’ve even tried my hand at podcasting. With this post I want to introduce people to the NetBeans IDE and to get us started [...]]]></description>
			<content:encoded><![CDATA[<p>As a Web Developer I naturally enjoy web development and writing a blog has always been on my mind. I start and stop and start and well. You get the message. I’ve even tried my hand at podcasting. With this post I want to introduce people to the NetBeans IDE and to get us started I want to show how to get a hello world running in java through a JSP page. In the future I&#8217;ll talk about Servlets and session handling but for now it&#8217;s get up and running time.</p>
<p>I love java for some reason. Maybe because it&#8217;s the first language I really sunk my teeth into.  Anyhow, first off any aspiring developer should download install and familiarize themselves with an IDE. IDE stands for Integrated Development Environment. Some people swear by Eclipse because of its extensibility and it has its uses but for me NetBeans has it made. It&#8217;s released by Sun, the JAVA people so it&#8217;s got some neat features like auto formatting that make a developers life easier.</p>
<p>So, first you need to travel to <a title="netBeans" href="http://www.netbeans.org/downloads/index.html" target="_blank">NetBeans.org</a> and download the latest version of NetBeans. You should be looking for the Java version or the all version. Really you just want a version that ticks the Java Web and EE box. Oh, and make sure you&#8217;ve got JavaScript enabled or you won&#8217;t see anything.</p>
<p><img class="alignnone size-full wp-image-5" title="netBeans Download" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/netbeansDownload.png" alt="netBeans Download" width="535" height="226" /></p>
<p>After NetBeans is downloaded you can go ahead and run it. Agree to everything as it loads. And after it loads simply go to file &gt; new project and you should see something looking like this:</p>
<p><img class="alignnone size-full wp-image-6" title="netBeans Hello World" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/demoWeb.png" alt="netBeans Hello World" width="515" height="254" /></p>
<p>Choose Java Web &gt; Web Application and click next. After you&#8217;ve done this you should see the next window in the &#8216;New Java Web Application Wizard. All you need o concern yourself with is the box i have highlighted, i.e. Give your new web application a name, I chose HelloWorld but you can choose any name you wish. It&#8217;s best if you don&#8217;t use spaces in the name just yet however.</p>
<p><img class="alignnone size-full wp-image-7" title="Java Web Application Wizard" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/demoWeb1.png" alt="Java Web Application Wizard" width="515" height="260" /></p>
<p>After you&#8217;ve chosen a name for your &#8216;Hello World&#8217; application you should select Next and then select Finish on the final page. In another post I will explain what each of the options mean specifically but for now we’re going to focus on the &#8216;Hello World&#8217;. There’s nothing like the first app feeling. As developers we are constantly learning new technologies and from time to time that feeling returns but the first is unique.</p>
<p>At this point you should see something like HTML code in the center of your screen. This is your editor window and here is where you will edit and manage all of your code.</p>
<p>To the left you should be seeing your project tree. It shows you index.jsp by default:</p>
<p><img class="alignnone size-full wp-image-8" title="Project and Files" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/projectFiles.png" alt="Project and Files" width="538" height="374" /></p>
<p>To execute your project you need to right click on your project and choose run from the drop down list. You will notice allot of things start to happen. JSP pages are compiled and rendered by a web server and displayed in your browser. So far this index.jsp page does nothing special and if its contents were contained in a .html page instead the browser would render it just the same.</p>
<p>Now, try adding this code to the top of your JSP page:</p>
<pre class="brush:[java]">&lt;%
String h = "hello";
String w = "world";
%&gt;</pre>
<p>And add this code to the between the body tags of your JSP page:</p>
<pre class="brush:[java]">&lt;h1&gt;
&lt;%= h + w + "!!" %&gt;
&lt;/h1&gt;</pre>
<p>Your page should look something like this after you’re done:</p>
<p><img class="alignnone size-full wp-image-9" title="JSP Hello World Example" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/projectFiles1.png" alt="JSP Hello World Example" width="482" height="354" /></p>
<p>Save the page in NetBeans and refresh the page in your browser and you get the same result, but this time you&#8217;ve been programming in java. Congratulations your Java Web story has begun. In the next post in the series I will explain what a String is and how it works. :)</p>
<p><map name='google_ad_map_1_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Fjava-web-hello-world%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/java-web-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
