<?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>Java, Programming, Struts2, jQuery, Linux and more &#187; java</title>
	<atom:link href="http://www.jgeppert.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jgeppert.com</link>
	<description>Johannes Geppert</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:31:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>4 Easy Steps to create a Java based Web Application with Struts2 and jQuery</title>
		<link>http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/</link>
		<comments>http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/#comments</comments>
		<pubDate>Tue, 10 May 2011 17:05:48 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Struts jQuery Plugin]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=542</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/' addthis:title='4 Easy Steps to create a Java based Web Application with Struts2 and jQuery '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Step1: Install and Configure Maven We use Maven to describe this software project and to manage the dependencies. 1.) Download maven from http://maven.apache.org/download.html and extract it. 2.) Add MAVEN_HOME/bin to your PATH Step2: Create your Struts2 Project 1.) Switch to your Eclipse Workspace. cd workspace 2.) Create the Project based on the struts2-archetype-convention archetype. mvn [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/' addthis:title='4 Easy Steps to create a Java based Web Application with Struts2 and jQuery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/' addthis:title='4 Easy Steps to create a Java based Web Application with Struts2 and jQuery '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><h2>Step1: Install and Configure Maven</h2>

<p>
We use <a href="http://maven.apache.org">Maven</a> to describe this software project and to manage the dependencies.
</p>

<p>
1.) Download maven from http://maven.apache.org/download.html and extract it.
</p>

<p>
2.) Add MAVEN_HOME/bin to your PATH
</p>

<h2>Step2: Create your Struts2 Project</h2>

<p>
1.) Switch to your Eclipse Workspace.
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> workspace</pre></div></div>




<p>
2.) Create the Project based on the <em>struts2-archetype-convention </em>archetype.
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn archetype:generate <span style="color: #660033;">-B</span> <span style="color: #660033;">-DgroupId</span>=com.jgeppert.examples <span style="color: #660033;">-DartifactId</span>=struts2-example <span style="color: #660033;">-DarchetypeGroupId</span>=org.apache.struts <span style="color: #660033;">-DarchetypeArtifactId</span>=struts2-archetype-convention <span style="color: #660033;">-DarchetypeVersion</span>=2.2.3</pre></div></div>




<p>
3.) Wait until maven download the whole Internet except Cats Pictures and Porn.
</p>

<p>
4.) Go into the new created folder struts2-example
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> struts2-example</pre></div></div>




<p>
5.) Open pom.xml in an Editor
</p>

<p>
6.) Set your project version to 0.0.1
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.0.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<p>
7.) Set your Struts2 Version to 2.2.3
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;struts2.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.2.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/struts2.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<p>
8.) Build your blank application
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>




<p>
9.) Try it out
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn jetty:run</pre></div></div>




<p>
10.) Open http://localhost:8080/struts2-example/ in your Browser
</p>

<p>
The Message "Struts is up and running..." should appear.
</p>

<h2>Step3: Create the Eclipse Project</h2>

<p>
1.) Open your Eclipse IDE
</p>

<p>
2.) Install <a href="http://m2eclipse.sonatype.org/installing-m2eclipse.html">m2-eclipse</a> and restart your IDE.
</p>

<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/1yOwMBYSq2A" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed wmode="opaque" src="http://www.youtube.com/v/1yOwMBYSq2A" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></p>

<p>
3.) Open the Import Dialog in your Eclipse IDE and import your created Project "struts2-example".

</p>

<p><img class="alignnone" title="Import Maven Project" src="http://www.jgeppert.com/struts2-jquery/import-maven-projects.jpg" alt="" /></p>

<p><img class="alignnone" title="Import Maven Project" src="http://www.jgeppert.com/struts2-jquery/struts2-example-project.jpg" alt="" /></p>


<h2>Step4: Add the Struts2 jQuery Plugin to your Project</h2>

<p>
The <a href="http://code.google.com/p/struts2-jquery/">Struts2 jQuery Plugin</a> provides an easy Integration of jQuery into this Project.
</p>

<p>
1.) Open your pom.xml and edit your project properties.
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;struts2.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.2.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/struts2.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;struts2jquery.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.0.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/struts2jquery.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<p>
2.) Add the Dependencies
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.jgeppert.struts2.jquery<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>struts2-jquery-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${struts2jquery.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>



	
<p>
3.) Create a new Action YourNameAction.java inside of the com.jgeppert.examples.actions Package
</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.jgeppert.examples.actions</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.opensymphony.xwork2.ActionSupport</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> YourNameAction <span style="color: #000000; font-weight: bold;">extends</span> ActionSupport <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>name <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> name.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    addActionError<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Please enter valid name with more the 2 characters!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000000; font-weight: bold;">return</span> ERROR<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> SUCCESS<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




<p>
4.) Replace the Content of hello.jsp
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;%@ page <span style="color: #000066;">contentType</span>=<span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;">&lt;%@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-tags&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;">&lt;%@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;sj&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-jquery-tags&quot;</span>%<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>My App<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sj:head</span> <span style="color: #000066;">jquerytheme</span>=<span style="color: #ff0000;">&quot;start&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    	body {
    		font-family: Arial,sans-serif;
    		font-size: 9pt;
    	}
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Please enter a Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:form</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;your-name&quot;</span> <span style="color: #000066;">theme</span>=<span style="color: #ff0000;">&quot;xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:textfield</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Enter your Name&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sj:submit</span> </span>
<span style="color: #009900;">			<span style="color: #000066;">targets</span>=<span style="color: #ff0000;">&quot;result&quot;</span> </span>
<span style="color: #009900;">			<span style="color: #000066;">effect</span>=<span style="color: #ff0000;">&quot;highlight&quot;</span> </span>
<span style="color: #009900;">			<span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Submit&quot;</span> </span>
<span style="color: #009900;">			<span style="color: #000066;">button</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h3<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>AJAX Result<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h3<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;result&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<p>
5.) Create a new JSP inside of your WEB-INF/content folder called your-name.jsp	
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;%@ page <span style="color: #000066;">contentType</span>=<span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;">&lt;%@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-tags&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Welcome <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<p>
6.) Create a new JSP inside of your WEB-INF/content folder called your-name-error.jsp	
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;%@ page <span style="color: #000066;">contentType</span>=<span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;">&lt;%@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-tags&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:actionerror</span> <span style="color: #000066;">theme</span>=<span style="color: #ff0000;">&quot;jquery&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>




<p>
7.) Run "mvn install" and "mvn jetty:run"
</p>

<p>
8.) Open http://localhost:8080/struts2-example/ in your Browser and our created form should be appear.
</p>
<p><img class="alignnone" title="Import Maven Project" src="http://www.jgeppert.com/struts2-jquery/hello-action.jpg" alt="" /></p>

<p>
9.) Submit without enter a Name. The Error Message should be visible inside of our defined Target Div without reloading the whole Page.
</p>

<p>
10.) Submit you form with an valid name.

</p>
<p><img class="alignnone" title="Import Maven Project" src="http://www.jgeppert.com/struts2-jquery/hello-action-success.jpg" alt="" /></p>

<p>
Download the <a href="http://www.jgeppert.com/struts2-jquery/struts2-jquery-example.zip">Sample Project Sources</a>.
</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/' addthis:title='4 Easy Steps to create a Java based Web Application with Struts2 and jQuery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2011/05/4-easy-steps-to-create-a-java-based-web-application-with-struts2-and-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Whats New in Struts2 jQuery Plugin 3.0.0</title>
		<link>http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/</link>
		<comments>http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/#comments</comments>
		<pubDate>Fri, 06 May 2011 11:16:24 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[projekte]]></category>
		<category><![CDATA[Struts jQuery Plugin]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[jstree]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=526</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/' addthis:title='Whats New in Struts2 jQuery Plugin 3.0.0 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>I'am happy to inform you that Version 3.0.0 of Struts2 jQuery Plugin is now available with a lot of new features an improvments. A new Tree Tag With this version there is an offen requested feature available. The new Tree Tag allows you to create easy Trees in your templates. This Tree Tag is based on [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/' addthis:title='Whats New in Struts2 jQuery Plugin 3.0.0 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/' addthis:title='Whats New in Struts2 jQuery Plugin 3.0.0 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I'am happy to inform you that Version 3.0.0 of <a href="http://code.google.com/p/struts2-jquery/">Struts2 jQuery Plugin</a> is now available with a lot of new features an improvments.</p>
<h2>A new Tree Tag</h2>
<p>With this version there is an offen requested feature available. The new Tree Tag allows you to create easy Trees in your templates. This Tree Tag is based on the great <a href="http://www.jstree.com/">jQuery jsTree Plugin</a>.</p>
<p><img class="alignnone" title="Struts2 jQuery Tree based on jsTree Plugin" src="http://www.jgeppert.com/struts2-jquery/struts2-jquery-tree.jpg" alt="" width="265" height="188" /></p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:tree</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;treeStatic&quot;</span> <span style="color: #000066;">jstreetheme</span>=<span style="color: #ff0000;">&quot;default&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;General&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://struts.apache.org/2.x/index.html&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2 @ Facebook&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://www.facebook.com/pages/Struts2-Users/103890046351798&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sjt:treeItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Plugins&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2 Plugins&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;https://cwiki.apache.org/S2PLUGINS/home.html&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2 jQuery Plugin&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://code.google.com/p/struts2-jquery/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2 Full Hibernate Plugin&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://code.google.com/p/full-hibernate-plugin-for-struts2/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sjt:treeItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Blogs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Struts2 jQuery News&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://www.jgeppert.com/category/java/struts2-jquery/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sjt:treeItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;AJAX Links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:url</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ajax1&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/ajax1.action&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Ajax 1&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;%{ajax1}&quot;</span> <span style="color: #000066;">targets</span>=<span style="color: #ff0000;">&quot;result&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:url</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ajax2&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/ajax2.action&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Ajax 2&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;%{ajax2}&quot;</span> <span style="color: #000066;">targets</span>=<span style="color: #ff0000;">&quot;result&quot;</span> <span style="color: #000066;">effect</span>=<span style="color: #ff0000;">&quot;highlight&quot;</span> <span style="color: #000066;">effectDuration</span>=<span style="color: #ff0000;">&quot;2500&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:url</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ajax3&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/ajax3.action&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Ajax 3&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;%{ajax3}&quot;</span> <span style="color: #000066;">targets</span>=<span style="color: #ff0000;">&quot;result&quot;</span> <span style="color: #000066;">onBeforeTopics</span>=<span style="color: #ff0000;">&quot;beforeLink&quot;</span> <span style="color: #000066;">onCompleteTopics</span>=<span style="color: #ff0000;">&quot;completeLink&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:url</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ajax4&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/ajax4.action&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjt:treeItem</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Ajax 4&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;%{ajax4}&quot;</span> <span style="color: #000066;">targets</span>=<span style="color: #ff0000;">&quot;result&quot;</span> <span style="color: #000066;">effect</span>=<span style="color: #ff0000;">&quot;bounce&quot;</span> <span style="color: #000066;">effectDuration</span>=<span style="color: #ff0000;">&quot;1000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sjt:treeItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sjt:treeItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sjt:tree<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<h2>Mobile Module</h2>
<p>For an better support of mobile development with Java and the popular MVC Framework Struts2, this version of <a href="http://code.google.com/p/struts2-jquery/">Struts2 jQuery Plugin</a> brings a new Module based on <a href="http://jquerymobile.com">jQuery mobile</a> to you. This includes an easy AJAX support and a jQuery mobile theme for form elements. The new <a href="http://www.weinfreund.de/struts2-jquery-mobile-showcase/index.action">Struts2 jQuery Mobile Showcase</a> gives you an introduction how to use this new module.</p>
<p><a href="http://www.weinfreund.de/struts2-jquery-mobile-showcase/index.action"><img src="http://www.jgeppert.com/struts2-jquery/struts2-jquery-mobile-showcase.jpeg" alt="Struts2 jQuery Mobile Showcase" /></a></p>
<h2>Grid Module</h2>
<p>This version provides an enhanced Subgrid Feature. Now it is possible to create Multilevel Subgrids. Please take a look at the new 3-Level Subgrid Example in the <a href="http://www.weinfreund.de/struts2-jquery-grid-showcase/index.action">Grid Showcase</a>.  </p>
<h2>Richtext Editor</h2>
<p>With this version it is easy to enable Uploads for Images and Flash files for your Ckeditor instance.</p>
<p><u>Enable File Uploads in your struts2.xml:</u></p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- Settings for CKEditor Image Upload --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constant</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;struts.ckeditor.allowUploads&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- default is false --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constant</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;struts.ckeditor.allowedFileExtensions&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;jpg,jpeg,png&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constant</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;struts.ckeditor.uploadFolder&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/image-uploads&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>



<p><u>Enable File Uploads in your ckeditor instance:</u></p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sjr:ckeditor</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;richtextEditor&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;echo&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">rows</span>=<span style="color: #ff0000;">&quot;10&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">cols</span>=<span style="color: #ff0000;">&quot;80&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;730&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;400&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">uploads</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>



<h2>Libary Updates</h2>
<ul>
<li><a href="http://blog.jquery.com/2011/03/31/jquery-152-released/">jQuery 1.5.2</a></li>
<li><a href="http://blog.jqueryui.com/2011/04/jquery-ui-1-8-12/">jQuery UI 1.8.12</a></li>
<li><a href="http://jquerymobile.com/blog/2011/04/07/jquery-alpha-4-1-maintenance-release/">jQuery Mobile Aplpha 4.1</a></li>
<li><a href="http://www.trirand.com/blog/?p=785">jqGrid 4.0.0</a></li>
<li>flot 0.7</li>
<li><a href="http://ckeditor.com/blog/CKEditor_3.5.3_released">ckEditor 3.5.3</a></li>
<li><a href="http://tinymce.moxiecode.com/forum/viewtopic.php?id=25470">tinyMCE 3.4.2</a></li>
</ul>
<p>For a complete list of changes since last version, please visit the <a href="http://code.google.com/p/struts2-jquery/wiki/Changelog">Changelog</a>.</p>
<p>Download: <a href="http://code.google.com/p/struts2-jquery/downloads/list">http://code.google.com/p/struts2-jquery/downloads/list</a><br />
Showcase: <a href="http://www.weinfreund.de/struts2-jquery-showcase/">http://www.weinfreund.de/struts2-jquery-showcase/</a><br />
Issues: <a href="http://code.google.com/p/struts2-jquery/issues/list">http://code.google.com/p/struts2-jquery/issues/list</a><br />
User Group: <a href="http://groups.google.com/group/struts2-jquery">http://groups.google.com/group/struts2-jquery</a></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/' addthis:title='Whats New in Struts2 jQuery Plugin 3.0.0 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2011/05/whats-new-in-struts2-jquery-plugin-3-0-0/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Preview for Struts2 jQuery Mobile Showcase</title>
		<link>http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/</link>
		<comments>http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 17:11:27 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Struts jQuery Plugin]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=496</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/' addthis:title='Preview for Struts2 jQuery Mobile Showcase '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>For an better support of mobile development with Java and the popular MVC Framework Struts2, I include in the next version of Struts2 jQuery Plugin a new Module based on jQuery mobile. Planned Features of the Struts2 Mobile Plugin are an easy AJAX support and a jQuery mobile theme for form elements. I just upload [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/' addthis:title='Preview for Struts2 jQuery Mobile Showcase ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/' addthis:title='Preview for Struts2 jQuery Mobile Showcase '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>For an better support of mobile development with Java and the popular MVC Framework Struts2, I include in the next version of <a href="http://code.google.com/p/struts2-jquery/">Struts2 jQuery Plugin</a> a new Module based on <a href="http://jquerymobile.com">jQuery mobile</a>. Planned Features of the Struts2 Mobile Plugin are an easy AJAX support and a jQuery mobile theme for form elements. I just upload the current development showcase for the new <a href="http://www.weinfreund.de/struts2-jquery-mobile-showcase/index.action">Struts2 jQuery Mobile Showcase</a>.

<a href="http://www.weinfreund.de/struts2-jquery-mobile-showcase/index.action"><img src="http://www.jgeppert.com/struts2-jquery/struts2-jquery-mobile-showcase.jpeg" alt="Struts2 jQuery Mobile Showcase" /></a>

The current module and showcase is based on the <a href="http://jquerymobile.com/2011/02/jquery-mobile-alpha-3-released/">jQuery mobile alpha 3</a> release.

I'm always open to suggestions.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/' addthis:title='Preview for Struts2 jQuery Mobile Showcase ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2011/02/preview-for-struts2-jquery-mobile-showcase/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sind Java Frameworks mit Java EE 6 obsolete?</title>
		<link>http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/</link>
		<comments>http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 15:09:28 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[jsf2]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=442</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/' addthis:title='Sind Java Frameworks mit Java EE 6 obsolete? '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Matt Raible antwortet in seinem Blog auf die von Cameron McKenzie bei TheServerSide aufgestellte These "Moving from Spring to Java EE 6: The Age of Frameworks is Over" mit einem klaren nein! Interessant fand ich die Aussage das JSF1 und JSF2 meist nur von Buch Autoren, MyFaces Entwicklern oder Java EE Vendors promoted wird, aber [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/' addthis:title='Sind Java Frameworks mit Java EE 6 obsolete? ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/' addthis:title='Sind Java Frameworks mit Java EE 6 obsolete? '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Matt Raible <a title="RE: Moving from Spring to Java EE 6: The Age of Frameworks is Over" href="http://raibledesigns.com/rd/entry/re_moving_from_spring_to">antwortet in seinem Blog</a> auf die von Cameron McKenzie bei TheServerSide aufgestellte These "<a href="http://www.theserverside.com/discussions/thread.tss?thread_id=61023">Moving from Spring to Java EE 6: The Age of Frameworks is Over</a>" mit einem klaren <strong>nein!</strong>

Interessant fand ich die Aussage das JSF1 und JSF2 meist nur von Buch Autoren, MyFaces Entwicklern oder Java EE Vendors promoted wird, aber die wenigsten Entwickler damit wirklich glücklich sind. Und lieber zu Java Frameworks wie Struts2 oder Spring MVC greifen sollten. Was ich persönlich auch bestätigen kann.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/' addthis:title='Sind Java Frameworks mit Java EE 6 obsolete? ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2010/10/sind-java-frameworks-mit-java-ee-6-obsolete/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Präsentation für Struts2 Einsteiger</title>
		<link>http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/</link>
		<comments>http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 20:08:10 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[präsentation]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=435</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/' addthis:title='Präsentation für Struts2 Einsteiger '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Auf seinem Blog hat iThoughts eine deutschsprachige Präsentation zur Verfügung gestellt, die (wie ich finde) einen gelungener Einstieg in die Web Programmierung mit Java und dem Framework Struts2 darstellt. Behandelt werden Themen wie: Warum Java und Warum Struts2? Model View Controller und MVC2 Struktur einer Struts2 Webanwendung Plugins Interceptors Best Practices ... Struts2 Präsentation für [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/' addthis:title='Präsentation für Struts2 Einsteiger ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/' addthis:title='Präsentation für Struts2 Einsteiger '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Auf seinem Blog hat <a href="http://www.ithoughts.de">iThoughts</a> eine deutschsprachige <a href="http://www.ithoughts.de/struts2-prasentation-fur-programmierer">Präsentation</a> zur Verfügung gestellt, die (wie ich finde) einen gelungener Einstieg in die Web Programmierung mit Java und dem Framework Struts2 darstellt.

Behandelt werden Themen wie:
<ul>
	<li>Warum Java und Warum Struts2?</li>
	<li>Model View Controller und MVC2</li>
	<li>Struktur einer Struts2 Webanwendung</li>
	<li>Plugins</li>
	<li>Interceptors</li>
	<li>Best Practices</li>
	<li>...</li>
</ul>

<a href="http://www.ithoughts.de/struts2-prasentation-fur-programmierer"><strong>Struts2 Präsentation für Programmierer</strong></a>

<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/' addthis:title='Präsentation für Struts2 Einsteiger ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2010/10/prasentation-fur-struts2-einsteiger/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java 4-Ever &#8211; Witziges Video .NET vs. Java</title>
		<link>http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/</link>
		<comments>http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:21:29 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[witze]]></category>
		<category><![CDATA[javazone]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=402</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/' addthis:title='Java 4-Ever &#8211; Witziges Video .NET vs. Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>A great promotional video for JavaZone 2010.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/' addthis:title='Java 4-Ever &#8211; Witziges Video .NET vs. Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/' addthis:title='Java 4-Ever &#8211; Witziges Video .NET vs. Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>A great promotional video for <a href="http://jz10.java.no/">JavaZone 2010</a>.<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/yl1f1-Da0OI" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed wmode="opaque" src="http://www.youtube.com/v/yl1f1-Da0OI" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/' addthis:title='Java 4-Ever &#8211; Witziges Video .NET vs. Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2010/07/java-4-ever-witziges-video-net-vs-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to parse a JSON Object when using multiSearch for jqGrid with Java</title>
		<link>http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/</link>
		<comments>http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 22:42:45 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[Struts jQuery Plugin]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[jqgrid]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JSONObject]]></category>
		<category><![CDATA[multiSearch]]></category>
		<category><![CDATA[parse]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=382</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/' addthis:title='How to parse a JSON Object when using multiSearch for jqGrid with Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>This is a tutorial that shows how to handle a JSON Object that is received in a Struts2 Action. This Example is based on the Struts2 Grid Showcase for the Struts2 jQuery Plugin with Grid Extension. 1. First we need to enable the Multi Search Feature for the Grid Component. &#60; sjg :grid id=&#34;customerstable&#34; ... [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/' addthis:title='How to parse a JSON Object when using multiSearch for jqGrid with Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/' addthis:title='How to parse a JSON Object when using multiSearch for jqGrid with Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>This is a tutorial that shows how to handle a JSON Object that is received in a <a href="http://struts.apache.org/2.x/">Struts2</a> Action. This Example is based on the <a href="http://www.weinfreund.de/struts2-jquery-grid-showcase/index.action">Struts2 Grid Showcase</a> for the <a href="http://code.google.com/p/struts2-jquery/">Struts2 jQuery Plugin</a> with Grid Extension.

1. First we need to enable the Multi Search Feature for the Grid Component.


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt; sjg :grid 
	id=&quot;customerstable&quot; 
	...
	navigatorSearch=&quot;true&quot;
	navigatorSearchOptions=&quot;{multipleSearch:true}&quot;
	...
&gt;</pre></div></div>


 

Now we can use the multiple search feature like this.

<img src="http://www.jgeppert.com/struts2-jquery/jqgrid_multiple_search.jpg" alt="struts2 jquery grid with multiple search" />

2.) After this we need a String property <strong>filter</strong> in our Struts2 Action.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> filters<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFilters<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> filters<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">filters</span> <span style="color: #339933;">=</span> filters<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


 

3.) Now we receive a JSON Object when we use the Search in the Navigator of the Grid. The JSON looks like this example.


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;groupOp&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;AND&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;rules&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">&quot;field&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;customernumber&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">&quot;op&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;lt&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;200&quot;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #339933;">,</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">&quot;field&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;country&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">&quot;op&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;eq&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;USA&quot;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




4.) To work with this, we need to serialize this as a JSONObject.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">JSONObject jsonFilter <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>JSONObject<span style="color: #009900;">&#41;</span> JSONSerializer.<span style="color: #006633;">toJSON</span><span style="color: #009900;">&#40;</span> filters <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>




5.) Now we can get the value from the JSON Object. First we get the parameter groupOp.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> groupOp <span style="color: #339933;">=</span> jsonFilter.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;groupOp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;groupOp :&quot;</span> <span style="color: #339933;">+</span> groupOp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>




6.) Now we need the rules as JSONArray and the size of this array.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">JSONArray rules <span style="color: #339933;">=</span> jsonFilter.<span style="color: #006633;">getJSONArray</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;rules&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> rulesCount <span style="color: #339933;">=</span> JSONArray.<span style="color: #006633;">getDimensions</span><span style="color: #009900;">&#40;</span>rules<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Count Rules :&quot;</span> <span style="color: #339933;">+</span> rulesCount<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>




7.) In a simple for-loop we can get the values of the rule.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> rulesCount<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	JSONObject rule <span style="color: #339933;">=</span> rules.<span style="color: #006633;">getJSONObject</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;field :&quot;</span> <span style="color: #339933;">+</span> rule.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;field&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;op :&quot;</span> <span style="color: #339933;">+</span> rule.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;op&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data :&quot;</span> <span style="color: #339933;">+</span> rule.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




Now you should be able to use this values to build a custom SQL 
query or build an hibernate criteria.</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/' addthis:title='How to parse a JSON Object when using multiSearch for jqGrid with Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Chuck Norris Witze über Java</title>
		<link>http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/</link>
		<comments>http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 14:58:35 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[witze]]></category>
		<category><![CDATA[chuck norris]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=347</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/' addthis:title='Chuck Norris Witze über Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Einfach Klasse: Chuck Norris kann Klassen erstellen die sowohl abstract als auch final sind. oder Chuck Norris braucht keine Unit Tests sein Code funktioniert immer. IMMER. Mehr davon gibt es bei ovisual.com<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/' addthis:title='Chuck Norris Witze über Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/' addthis:title='Chuck Norris Witze über Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Einfach Klasse:
<p style="padding-left: 30px;"><em>Chuck Norris kann Klassen erstellen die sowohl <strong>abstract</strong> als auch <strong>final</strong> sind.</em></p>
oder
<p style="padding-left: 30px;"><em>Chuck Norris braucht keine Unit Tests sein Code funktioniert immer. IMMER.</em></p>
Mehr davon gibt es bei <a href="http://www.ovisual.com/4/">ovisual.com</a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/' addthis:title='Chuck Norris Witze über Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2010/01/chuck-norris-witze-uber-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webservice Client mit jdk6 Tool wsimport</title>
		<link>http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/</link>
		<comments>http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/#comments</comments>
		<pubDate>Wed, 27 May 2009 13:47:00 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[jdk6]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[webservice]]></category>
		<category><![CDATA[wsdl]]></category>
		<category><![CDATA[wsimport]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=247</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/' addthis:title='Webservice Client mit jdk6 Tool wsimport '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Passend zu meinen letzten Artikeln über Clients für REST Webservices mit Jersey und Webservices mit Axis2 und Spring bin ich heute über den Artikel bei jars.de über die Generierung von Webservices mit dem Tool wsimport gestoßen. Webservices Clients mit wsimport generieren jars.de zeigt wie man auf der Kommandozeile Clients aus einer WSDL Url generieren kann. [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/' addthis:title='Webservice Client mit jdk6 Tool wsimport ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/' addthis:title='Webservice Client mit jdk6 Tool wsimport '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Passend zu meinen letzten Artikeln über Clients für <a href="http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/">REST Webservices mit Jersey</a> und <a href="http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/">Webservices mit Axis2 und Spring</a> bin ich heute über den Artikel bei <a href="http://jars.de">jars.de</a> über die Generierung von Webservices mit dem Tool <strong>wsimport</strong> gestoßen. 

<strong><a href="http://jars.de/java/wsimport-web-service-client-generieren">Webservices Clients mit <em>wsimport</em> generieren</a></strong>

<a href="http://jars.de">jars.de</a> zeigt wie man auf der Kommandozeile Clients aus einer WSDL Url generieren kann.

<strong>Weiter Artikel:</strong>
<a href="http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/">Java Client für REST WebService (JAX-RS) </a>
<a href="http://www.jgeppert.com/2009/05/php-client-rest-webservice/">PHP Client für REST WebService</a> <div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/' addthis:title='Webservice Client mit jdk6 Tool wsimport ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/05/webservice-client-mit-jdk6-tool-wsimport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Client für REST WebService (JAX-RS)</title>
		<link>http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/</link>
		<comments>http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/#comments</comments>
		<pubDate>Mon, 25 May 2009 13:19:18 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[jax-rc]]></category>
		<category><![CDATA[jersey]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[rest client]]></category>
		<category><![CDATA[restful]]></category>
		<category><![CDATA[restservice]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[webservice]]></category>
		<category><![CDATA[webservice client]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=233</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/' addthis:title='Java Client für REST WebService (JAX-RS) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Nach dem Erstellen eines REST WebServices mit JAX-RS habe ich schon ein Beispiel für einen PHP Client eines WebServices gegeben. Natürlich lässt sich der REST WebService auch mit Java exzellent verarbeiten. Wie das geht werde ich in einem kleinen Beispiel demonstrieren. Der Client ruft den REST Web Service aus dem Tutorial für REST WebServices mit [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/' addthis:title='Java Client für REST WebService (JAX-RS) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/' addthis:title='Java Client für REST WebService (JAX-RS) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Nach dem Erstellen eines <a href="http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/">REST WebServices mit JAX-RS</a> habe ich schon ein Beispiel für einen <a href="http://www.jgeppert.com/2009/05/php-client-rest-webservice/">PHP Client eines WebServices</a> gegeben. Natürlich lässt sich der REST WebService auch mit Java exzellent verarbeiten. Wie das geht werde ich in einem kleinen Beispiel demonstrieren. Der Client ruft den REST Web Service aus dem <a href="http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/">Tutorial für REST WebServices mit Jersey</a> auf und benötigt auch die meisten JAR-Files aus diesem Beispiel. Zusätzlich wird noch das <a title="Jersay Client Jar" href="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.2/jersey-client-1.0.2.jar">jersey-client-1.0.2.jar</a> benötigt.

Jersey stellt uns für den einfachen Zugriff die Klassen <em>Client</em> und <em>WebResource</em> bereit.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">		Client client <span style="color: #339933;">=</span> Client.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		WebResource wr <span style="color: #339933;">=</span> client.<span style="color: #006633;">resource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://localhost:8080/wstest/services/calculator/calc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>




Mit Hilfe von <em>WebResource</em> können wir mit den HTTP Methoden <em>post()</em>, <em>delete()</em>, <em>put()</em> und natürlich <em>get()</em> unseren WebService aufrufen. Und mit der <em>MultivaluedMap</em> ist es uns möglich, dem WebService unsere Abfrageparameter mitzugeben.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wstest.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ws.rs.core.MediaType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ws.rs.core.MultivaluedMap</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.jersey.api.client.Client</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.jersey.api.client.GenericType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.jersey.api.client.WebResource</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.jersey.core.util.MultivaluedMapImpl</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">de.wstest.MathResults</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">de.wstest.ServiceResult</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CalculatorClient <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		Client client <span style="color: #339933;">=</span> Client.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//URL des WebService</span>
		WebResource wr <span style="color: #339933;">=</span> client.<span style="color: #006633;">resource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://localhost:8080/wstest/services/calculator/calc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Parameter für WebService</span>
		MultivaluedMap<span style="color: #339933;">&lt;</span> <span style="color: #003399;">String</span>, <span style="color: #003399;">String</span> <span style="color: #339933;">&gt;</span> params <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MultivaluedMapImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		params.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span>, <span style="color: #0000ff;">&quot;234&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		params.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;b&quot;</span>, <span style="color: #0000ff;">&quot;567&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		ServiceResult sr <span style="color: #339933;">=</span> wr.<span style="color: #006633;">queryParams</span><span style="color: #009900;">&#40;</span>params<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">accept</span><span style="color: #009900;">&#40;</span>MediaType.<span style="color: #006633;">APPLICATION_XML_TYPE</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GenericType<span style="color: #339933;">&lt;</span> ServiceResult <span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Ergebnis ausgeben</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>sr.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span> MathResults <span style="color: #339933;">&gt;</span> mathResults <span style="color: #339933;">=</span> sr.<span style="color: #006633;">getErgebnisse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>MathResults mr <span style="color: #339933;">:</span> mathResults<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>mr.<span style="color: #006633;">getFormel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; = &quot;</span><span style="color: #339933;">+</span>mr.<span style="color: #006633;">getErgebniss</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




Die Ausgabe des WebServices ist wenig überraschend:
<code>
Results for Value a = 234, Value b = 567
a + b = 801
a - b = -333
a * b = 132678
</code>

<strong>FAZIT:</strong>
Wie man sieht, ist mit Hilfe der Jersey Klassen eine einfache Abfrage von REST WebServices möglich.

Ausführlichere Beispiele findet man auf den <a href="http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with">Enterprise Tech Tips</a> Seiten von SUN, in welchem die Twitter Webservices benutzt werden. Dort gibt es dann auch Beispiele für das Benutzen der PUT, POST und DELETE Methoden.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/' addthis:title='Java Client für REST WebService (JAX-RS) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/05/java-client-fuer-restful-web-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Neue Version des Java Mass JPEG Resizer Tools</title>
		<link>http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/</link>
		<comments>http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/#comments</comments>
		<pubDate>Thu, 14 May 2009 12:43:57 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[projekte]]></category>
		<category><![CDATA[gallerie]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[web gallerie]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=227</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/' addthis:title='Neue Version des Java Mass JPEG Resizer Tools '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Seit heute ist die neue Version 0.8 des Java Mass JPEG Resizer Tool veröffentlicht. Die wichtigsten Änderungen sind folgende: - Verbesserung der Performance Version 0.7 hat auf meiner Dual Core Maschine bei 100 Bildern noch 2:26 Minuten gebraucht, mit der neuen Version wurden nur noch 1:21 Minuten benötigt. - Eine neue Web Gallery Die neue [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/' addthis:title='Neue Version des Java Mass JPEG Resizer Tools ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/' addthis:title='Neue Version des Java Mass JPEG Resizer Tools '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Seit heute ist die neue Version 0.8 des <a href="http://jmjrst.sourceforge.net/">Java Mass JPEG Resizer Tool</a> veröffentlicht.

<span style="text-decoration: underline;">Die wichtigsten Änderungen sind folgende:</span>

<strong>- Verbesserung der Performance</strong>
Version 0.7 hat auf meiner Dual Core Maschine bei 100 Bildern noch 2:26 Minuten gebraucht, mit der neuen Version wurden nur noch 1:21 Minuten benötigt.

<strong>- Eine neue Web Gallery</strong>
Die neue Web Gallerie "A Fancybox Slideshow" basiert auf dem JavaScript Framework <a href="http://jquery.com">jQuery </a>und dem Plugin <a href="http://fancy.klade.lv">Fancybox</a>.

<strong>- Und dann natürlich noch einige kleine Fehlerbehebungen</strong>

<a href="https://sourceforge.net/project/showfiles.php?group_id=192740">Download</a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/' addthis:title='Neue Version des Java Mass JPEG Resizer Tools ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/05/neue-version-des-java-mass-jpeg-resizer-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Framework Struts2 &#8211; AJAX mit Dojo oder jQuery?</title>
		<link>http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/</link>
		<comments>http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/#comments</comments>
		<pubDate>Mon, 11 May 2009 20:33:08 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=215</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/' addthis:title='Java Framework Struts2 &#8211; AJAX mit Dojo oder jQuery? '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Für Webanwendungen die ich mit Java erstelle, verwende ich seit einigen Jahren Struts und seit einiger Zeit Struts2. Struts2 hat außer dem Namen nicht sehr viel mit dem älteren und weit verbreiteten Struts gemeinsam, sondern es basiert auf dem Framework Webworks. Das Tolle an Struts2 ist seine Flexibilität. So gibt es für verschiedenste Einsatzzwecke Plugins [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/' addthis:title='Java Framework Struts2 &#8211; AJAX mit Dojo oder jQuery? ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/' addthis:title='Java Framework Struts2 &#8211; AJAX mit Dojo oder jQuery? '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Für Webanwendungen die ich mit Java erstelle, verwende ich seit einigen Jahren Struts und seit einiger Zeit <a href="http://struts.apache.org/2.x/">Struts2</a>. Struts2 hat außer dem Namen nicht sehr viel mit dem älteren und weit verbreiteten Struts gemeinsam, sondern es basiert auf dem Framework Webworks. Das Tolle an Struts2 ist seine Flexibilität. So gibt es für verschiedenste Einsatzzwecke <a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugins</a> z.B. ein <a href="http://code.google.com/p/s2-rome/">Rome Plugin</a> zum Erzeugen von RSS Feeds oder eine <a href="http://struts.apache.org/2.x/docs/jfreechart-plugin.html">JFreeChart Plugin</a>, um Charts in die Webanwendung zu integrieren.

Da moderne Webanwendungen häufig sehr AJAX lastig sind, bei <a href="http://www.weinfreund.de">weinfreund.de</a> verwende ich z.B. sehr viel AJAX im Backend und im Administrationsbereich, bringt Struts2 gleich ein Dojo Plugin von Haus aus mit. Mit dem Plugin ist es möglich, ohne Kenntnisse von JavaScript AJAX Funktionalität in die Anwendung einzubauen.

Folgendes Beispiel zeigt, wie man das Ergebnis eines Links per AJAX in ein DIV lädt.


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt; %@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-tags&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;">&lt; %@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;sx&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-dojo-tags&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sx</span> :head <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Ein leeres Div in das unser Ergebnis geladen wird --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ziel&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Unser Link, durch das Attribut targets wird das Ergebnis automatisch in unser oben definiertes DIV geladen. --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sx</span> :a <span style="color: #000066;">targets</span>=<span style="color: #ff0000;">&quot;div&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Google Startseite&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://www.google.de&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>




Das Dojo Plugin bringt auch einige UI Elemente wie <strong>Tabs</strong>, <strong>Autocompleter</strong>, <strong>Kalender </strong>und mehr mit, die ähnlich einfach wie der Link zu benutzen gehen.

<strong>Warum jQuery?</strong>

Da ich mit dem Dojo Plugin an einige Grenzen gestoßen bin, z.B. bei Fileupload und JavaScript in AJAX-Results, und es auch viel Aufwand ist, die Optik an die eigene Webseite anzupassen, habe ich <a href="http://jquery.com/">jQuery</a> ausprobiert.

Leider gibt es noch kein Plugin was einem häufige Funktionen genauso erleichtern wie das Dojo Plugin. Bis jetzt gibt es nur Alpha Versionen und Entwicklerversionen eines solchen Plugins. Ich habe <a href="http://jquery.com/">jQuery</a> mit purem JavaScript benutzt. Das erfordert zwar einen erhöhten Programmieraufwand und Einarbeitung in JavaScript, aber jQuery hat einen leicht  zu erlernenden Syntax, eine große Community und <a href="http://plugins.jquery.com/">Plugins</a> für fast jeden Einsatzzweck. 

Mit jQuery sieht das gleiche Beispiel von oben so aus.


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;scripts/jquery-1.3.2.min.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  $(document).ready(function() {
    $(&quot;#googlelink&quot;).click(function()	{
      $(&quot;#ziel&gt;&quot;).load(&quot;http://www.google.de&quot;);
    });
  });
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ziel&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;googlelink&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:void(0)&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Google Startseite<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




Das Ganze ist zwar nicht so schick zu lesen wie mit dem Dojo Plugin, aber mit etwas Erfahrung hat man mit jQuery eine bessere Kontrolle über den Code und ist flexibler.

Auch jQuery bringt mit Hilfe von <a href="http://jqueryui.com/">jQuery UI</a> leicht zu benutzende Widgets wie <strong>Tabs</strong>, <strong>Dialogboxen </strong>und <strong>Kalender </strong>mit, welche auch noch mit dem <a href="http://jqueryui.com/themeroller/">Themeroller</a> leicht an das eigene Layout anpassbar sind.

<strong>Fazit:</strong>
Mit jQuery hat man eine gute Alternative zum Struts2 Dojo Plugin, da man dieses flexibler an eigene Bedürfnisse anpassen und mit Plugins auch besser erweitern kann. Vielleicht gibt es ja für Struts2 auch bald ein brauchbares jQuery Plugin, so dass man es genauso einfach wie Dojo benutzen kann.
Ich kann den Einsatz von jQuery für AJAX basierte Webanwendungen nur empfehlen.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/' addthis:title='Java Framework Struts2 &#8211; AJAX mit Dojo oder jQuery? ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/05/java-framework-struts2-mit-dojo-oder-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RESTful Web Services (JAX-RS) mit Jersey</title>
		<link>http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/</link>
		<comments>http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 10:59:32 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[jax-rc]]></category>
		<category><![CDATA[jersey]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=189</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/' addthis:title='RESTful Web Services (JAX-RS) mit Jersey '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Durch das Jersey Projekt existieren Bibliotheken die es Java Entwicklern besonders einfach machen REST Web Services zu entwickeln. In diesem Tutorial werde ich zeigen wie einfach es ist eine Web Service zu schreiben der uns einfache Mathematische Berechnung zurückliefert. 1.) Wir erstellen in unserer Entwicklungsumgebung, in meinem Beispiel Eclipse, ein Web Projekt.  In das WEB-INF/lib [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/' addthis:title='RESTful Web Services (JAX-RS) mit Jersey ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/' addthis:title='RESTful Web Services (JAX-RS) mit Jersey '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Durch das <a href="https://jersey.dev.java.net/">Jersey</a> Projekt existieren Bibliotheken die es Java Entwicklern besonders einfach machen REST Web Services zu entwickeln. In diesem Tutorial werde ich zeigen wie einfach es ist eine Web Service zu schreiben der uns einfache Mathematische Berechnung zurückliefert.

1.)
Wir erstellen in unserer Entwicklungsumgebung, in meinem Beispiel Eclipse, ein Web Projekt.  In das <strong>WEB-INF/lib</strong> Verzeichnis packen wir alle für Jersey benötigten JARs die es bei <a href="https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/jersey/dependencies.html">Jersey/Downloads</a> runterzuladen gibt.  Für dieses Tutorial benötigen wir folgende Bibliotheken:<a href="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.2/jersey-server-1.0.2.jar"> jersey-server.jar</a>, <a href="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.2/jersey-core-1.0.2.jar">jersey-core.jar</a>, <a href="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0.jar">jsr311-api.jar</a>, <a href="http://repo1.maven.org/maven2/asm/asm/3.1/asm-3.1.jar">asm.jar, </a><a href="http://download.java.net/maven/1/com.sun.xml.bind/jars/jaxb-impl-2.1.jar">jaxb-impl.jar</a>, <a href="http://download.java.net/maven/1/javax.xml.bind/jars/jaxb-api-2.1.jar">jaxb-api.jar</a>, <a href="http://download.java.net/maven/1/javax.activation/jars/activation-1.1.jar">activation.jar</a>, <a href="http://download.java.net/maven/1/javax.xml.stream/jars/stax-api-1.0-2.jar">stax-api.jar</a>

2.)
In unserer <strong>WEB-INF/web.xml</strong> fügen wir folgendes hinzu:


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>JAX-RS REST Servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>REST-Servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  		com.sun.jersey.spi.container.servlet.ServletContainer
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>REST-Servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/services/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




3.)
Wir erstellen zwei Klassen die wir für unser Ergebniss benötigen.

Die erste Klasse <strong>MathResults</strong> kapselt unsere Mathematischen Ergebnisse.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wstest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MathResults <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> formel<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> ergebniss<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getFormel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> formel<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFormel<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> formel<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">formel</span> <span style="color: #339933;">=</span> formel<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getErgebniss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> ergebniss<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setErgebniss<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> ergebniss<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ergebniss</span> <span style="color: #339933;">=</span> ergebniss<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



Und die zweite Klasse <strong>ServiceResult</strong> ist das Result unseres WebService


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wstest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.bind.annotation.XmlRootElement</span><span style="color: #339933;">;</span>
&nbsp;
@XmlRootElement
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceResult <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> message<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> returncode<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>MathResults<span style="color: #339933;">&gt;</span> ergebnisse<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getReturncode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> returncode<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setReturncode<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> returncode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">returncode</span> <span style="color: #339933;">=</span> returncode<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> message<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setMessage<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">message</span> <span style="color: #339933;">=</span> message<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>MathResults<span style="color: #339933;">&gt;</span> getErgebnisse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> ergebnisse<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setErgebnisse<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>MathResults<span style="color: #339933;">&gt;</span> ergebnisse<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ergebnisse</span> <span style="color: #339933;">=</span> ergebnisse<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




4.)
Jetzt erstellen wir eine weitere Klasse <strong>CalculatorService</strong>, diese ist unser eigentlicher Webservice und wird durch Annotions als dieser gekennzeichnet. Ein gute Übersicht über zulässige Annotions findet Ihr im <a href="http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features">Wiki von Jersey</a>.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wstest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.LinkedList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ws.rs.GET</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ws.rs.Path</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ws.rs.Produces</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ws.rs.QueryParam</span><span style="color: #339933;">;</span>
&nbsp;
@Produces<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/xml&quot;</span><span style="color: #009900;">&#41;</span>
@Path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;calculator&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CalculatorService <span style="color: #009900;">&#123;</span>
&nbsp;
	@GET
	@Path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;calc&quot;</span><span style="color: #009900;">&#41;</span>
	@Produces<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/xml&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> ServiceResult add<span style="color: #009900;">&#40;</span>@QueryParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">Integer</span> a, @QueryParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;b&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">Integer</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		ServiceResult r <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ServiceResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span>MathResults<span style="color: #339933;">&gt;</span> ergs <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LinkedList<span style="color: #339933;">&lt;</span>MathResults<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> b <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			r.<span style="color: #006633;">setMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No Values!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			r.<span style="color: #006633;">setReturncode</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			r.<span style="color: #006633;">setErgebnisse</span><span style="color: #009900;">&#40;</span>ergs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> r<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		r.<span style="color: #006633;">setMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Results for Value a = &quot;</span><span style="color: #339933;">+</span>a<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, Value b = &quot;</span><span style="color: #339933;">+</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		r.<span style="color: #006633;">setReturncode</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		MathResults e1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MathResults<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		e1.<span style="color: #006633;">setFormel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a + b&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		e1.<span style="color: #006633;">setErgebniss</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">+</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		MathResults e2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MathResults<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		e2.<span style="color: #006633;">setFormel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a - b&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		e2.<span style="color: #006633;">setErgebniss</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">-</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		MathResults e3 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MathResults<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		e3.<span style="color: #006633;">setFormel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a * b&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		e3.<span style="color: #006633;">setErgebniss</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">*</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		ergs.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>e1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ergs.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>e2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ergs.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>e3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		r.<span style="color: #006633;">setErgebnisse</span><span style="color: #009900;">&#40;</span>ergs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> r<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




Fertig ist unsere RESTFull Webservice. Nach dem deployen in einem ServletContainer wie Tomcat erhalten wir nach einem Aufruf des Webservices im Browser

<em>http://localhost:8080/wstest/services/calculator/calc?a=234&amp;b=456</em>

folgendes Ergebniss:


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serviceResult<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ergebnisse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ergebniss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>690<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ergebniss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;formel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a + b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/formel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ergebnisse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ergebnisse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ergebniss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>-222<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ergebniss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;formel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a - b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/formel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ergebnisse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ergebnisse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ergebniss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>106704<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ergebniss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;formel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a * b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/formel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ergebnisse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;message<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Value a = 234, Value b = 456<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/message<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;returncode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/returncode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/serviceResult<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




Durch einen Aufruf der URL

<em>http://localhost:8080/wstest/services/application.wadl</em>

erhalten wir eine Übersicht über unsere Services und deren Parameter.


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://research.sun.com/wadl/2006/10&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;doc</span> <span style="color: #000066;">xmlns:jersey</span>=<span style="color: #ff0000;">&quot;http://jersey.dev.java.net/&quot;</span> <span style="color: #000066;">jersey:generatedBy</span>=<span style="color: #ff0000;">&quot;Jersey: 1.0 10/13/2008 12:27 PM&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resources</span> <span style="color: #000066;">base</span>=<span style="color: #ff0000;">&quot;http://localhost:8080/wstest/services/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;calculator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;calc&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;GET&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;add&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;request<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:int&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;query&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:int&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;query&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/request<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;response<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;representation</span> <span style="color: #000066;">mediaType</span>=<span style="color: #ff0000;">&quot;application/xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/response<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




Fertig ist in wenigen Schritten unser REST Web Service der uns eine Liste von Berechnungen für einen Eingabe zurückliefert.
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/' addthis:title='RESTful Web Services (JAX-RS) mit Jersey ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/03/restful-web-services-jax-rs-mit-jersey/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Ein Webservice mit Axis2 und Spring</title>
		<link>http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/</link>
		<comments>http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 18:16:42 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[axis2]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=165</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/' addthis:title='Ein Webservice mit Axis2 und Spring '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Mit Axis2 ist das Erstellen von Webservices für Java Programmierer noch einfacher geworden. Mit folgendem kleinen Beispiel will ich zeigen, wie man einen Webservice programmieren kann, der von Spring ein Bean injiziert bekommt. Als Erstes erstellen wir unseren Webservice als einfache Java Klasse: package com.jgeppert.services; &#160; import com.jgeppert.dao.MyDAO; &#160; private MyDAO myDAO; &#160; public class [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/' addthis:title='Ein Webservice mit Axis2 und Spring ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/' addthis:title='Ein Webservice mit Axis2 und Spring '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Mit <a href="http://ws.apache.org/axis2/">Axis2</a> ist das Erstellen von Webservices für Java Programmierer noch einfacher geworden. Mit folgendem kleinen Beispiel will ich zeigen, wie man einen Webservice programmieren kann, der von <a href="http://www.springsource.org">Spring</a> ein Bean injiziert bekommt.
</p>
<p>
Als Erstes erstellen wir unseren Webservice als einfache Java Klasse:
</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.jgeppert.services</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.jgeppert.dao.MyDAO</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> MyDAO myDAO<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyWebService
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/* Die Funktion add() ist unsere Webservice Operation die
	 * dann mit einem Client angesprochen werden kann.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> add<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> text<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			myDAO.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;insert successfully&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">RuntimeException</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Mit dieser Methode injiziert uns Spring unser DAO Objekt</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> setMyDAO<span style="color: #009900;">&#40;</span>MyDAO myDAO<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">myDAO</span> <span style="color: #339933;">=</span> myDAO<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



<p>
Als Zweites brauchen wir für Aris2 eine service.xml mit folgendem Inhalt:
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>My First WebService<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ServiceClass&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		com.jgeppert.services.MyWebService
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/parameter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ServiceObjectSupplier&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/parameter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SpringBeanName&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>myWebService<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/parameter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;add&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;messageReceiver</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.axis2.rpc.receivers.RPCMessageReceiver&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/operation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>



<p>
Für Spring sind die zwei Parameter <strong>ServiceObjectSupplier</strong> und <strong>SpringBeanName</strong> entscheidend, um uns das benötigte DAO zu übergeben.

Mit Hilfe eines <a href="http://ws.apache.org/axis2/1_4_1/pojoguide.html#buildpojows">Ant Scriptes</a> oder manuell kann man sich den Webservice in das für Axis2 benötigte AAR Archiv packen. Das Archiv ist im Grunde eine normale JAR Datei mit der service.xml im META-INF Verzeichnis.
</p>
<p>
Die Struktur des AAR-Archives sollte so aus sehen:
</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">-</span> MyWebService
   <span style="color: #339933;">-</span> META<span style="color: #339933;">-</span>INF
     <span style="color: #339933;">-</span> services.<span style="color: #006633;">xml</span>
   <span style="color: #339933;">-</span> com
     <span style="color: #339933;">-</span> jgeppert
       <span style="color: #339933;">-</span> services
         <span style="color: #339933;">-</span> MyWebService.<span style="color: #000000; font-weight: bold;">class</span></pre></div></div>



<p>
Damit Spring unser DAO in dem Service injizieren kann, brauchen wir noch folgenden Eintrag in unserer applicationContext.xml.</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;applicationContext&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myWebService&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.jgeppert.services.MyWebService&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;myDAO&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;MyDAO&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>



<p>
Nach dem deployen des AAR-Archives im services Folder der Axis2 Web Application steht der Service nun zur Verfügung.
</p><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/' addthis:title='Ein Webservice mit Axis2 und Spring ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/02/webservice-mit-axis2-und-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mit Java twittern</title>
		<link>http://www.jgeppert.com/2009/01/mit-java-twittern/</link>
		<comments>http://www.jgeppert.com/2009/01/mit-java-twittern/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 09:10:41 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[tweet]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=154</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/01/mit-java-twittern/' addthis:title='Mit Java twittern '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Da Twitter ja gerade stark in Mode ist, will ich an dieser Stelle mal ein kleines Beispiel bringen wie man mit Java automatisiert twittern kann. Ich nutze das z.B. um bei http://twitter.com/weinfreund über die neusten Aktivitäten, wie neue Weingüter, Weine, Forenbeiträge usw., bei weinfreund.de zu informieren. import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Serializable; import java.net.URL; [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/01/mit-java-twittern/' addthis:title='Mit Java twittern ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2009/01/mit-java-twittern/' addthis:title='Mit Java twittern '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Da Twitter ja gerade stark in Mode ist, will ich an dieser Stelle mal ein kleines Beispiel bringen wie man mit Java automatisiert twittern kann. Ich nutze das z.B. um bei <a href="http://twitter.com/weinfreund">http://twitter.com/weinfreund</a> über die neusten Aktivitäten, wie neue Weingüter, Weine, Forenbeiträge usw., bei <a title="Der Weinfreund - Weine direkt vom Weingut" href="http://www.weinfreund.de">weinfreund.de</a> zu informieren.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStreamReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.OutputStreamWriter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.URL</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.URLConnection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.URLEncoder</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.logging.Log</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.logging.LogFactory</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TwitterService <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span>	serialVersionUID	<span style="color: #339933;">=</span> 9080041366457990472L<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Log  log <span style="color: #339933;">=</span> LogFactory.<span style="color: #006633;">getLog</span><span style="color: #009900;">&#40;</span>TwitterService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> user<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> passwort<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> TwitterService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> TwitterService<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> user, <span style="color: #003399;">String</span> passwort<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">user</span> <span style="color: #339933;">=</span> user<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">passwort</span> <span style="color: #339933;">=</span> passwort<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> post<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> message<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">URLConnection</span> connection <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> credentials <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">user</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;:&quot;</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">passwort</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> encodecredentials <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sun.<span style="color: #006633;">misc</span>.<span style="color: #006633;">BASE64Encoder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">encode</span><span style="color: #009900;">&#40;</span>credentials.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003399;">URL</span> url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://twitter.com/statuses/update.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> encodedData <span style="color: #339933;">=</span> <span style="color: #003399;">URLEncoder</span>.<span style="color: #006633;">encode</span><span style="color: #009900;">&#40;</span>message, <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			connection <span style="color: #339933;">=</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			connection.<span style="color: #006633;">setRequestProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Authorization&quot;</span>, <span style="color: #0000ff;">&quot;Basic &quot;</span> <span style="color: #339933;">+</span> encodecredentials<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			connection.<span style="color: #006633;">setDoOutput</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003399;">OutputStreamWriter</span> out <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">OutputStreamWriter</span><span style="color: #009900;">&#40;</span>connection.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			out.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;status=&quot;</span> <span style="color: #339933;">+</span> encodedData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			out.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>connection.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> line<span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> in.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			in.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			log.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> user<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">user</span> <span style="color: #339933;">=</span> user<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setPasswort<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> passwort<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">passwort</span> <span style="color: #339933;">=</span> passwort<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




Die Klasse TwitterService läßt sich nun einfach mittels Spring in benötigte Klassen injizieren.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2009/01/mit-java-twittern/' addthis:title='Mit Java twittern ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2009/01/mit-java-twittern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mit dem Spring Framework einen Scheduler ausführen</title>
		<link>http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/</link>
		<comments>http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 09:35:25 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[quartz]]></category>
		<category><![CDATA[scheduler]]></category>
		<category><![CDATA[springframework]]></category>
		<category><![CDATA[timertask]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=125</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/' addthis:title='Mit dem Spring Framework einen Scheduler ausführen '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Spring bietet uns die Möglichkeit, wiederkehrende Aufgaben auszuführen. Die einfachste Variante einen Scheduler zu implementieren, die ich hier zeigen werde, ist das Ausführen eines TimerTask. Dazu implementiert man als erstes eine Klasse die von TimerTask ableitet. In der Methode run() können wir jetzt unseren Code ausführen. In diesem Beispiel lassen wir uns von Spring gleich [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/' addthis:title='Mit dem Spring Framework einen Scheduler ausführen ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/' addthis:title='Mit dem Spring Framework einen Scheduler ausführen '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><a href="http://www.springframework.org/">Spring</a> bietet uns die Möglichkeit, wiederkehrende Aufgaben auszuführen. Die einfachste Variante einen Scheduler zu implementieren, die ich hier zeigen werde, ist das Ausführen eines <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/TimerTask.html">TimerTask</a>.

Dazu implementiert man als erstes eine Klasse die von <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/TimerTask.html">TimerTask</a> ableitet. In der Methode <em>run()</em> können wir jetzt unseren Code ausführen. In diesem Beispiel lassen wir uns von <a href="http://www.springframework.org/">Spring</a> gleich noch ein DAO Objekt übergeben mit dem wir eine Datenbank Operation ausführen können.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyTimerTask <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">TimerTask</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Log log <span style="color: #339933;">=</span> LogFactory.<span style="color: #006633;">getLog</span><span style="color: #009900;">&#40;</span>MyTimerTask.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> MeinDAO meinDAO<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		log.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Starte MyTimerTask &quot;</span><span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Etwas sinnvolles machen!</span>
		meinDAO.<span style="color: #006633;">deleteAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		log.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Beende MyTimerTask &quot;</span><span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setMeinDAO<span style="color: #009900;">&#40;</span>MeinDAO meinDAO<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">meinDAO</span> <span style="color: #339933;">=</span> meinDAO<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




Jetzt müssen wir nur noch unsere <em>applicationContext.xml</em> um folgende Einträge erweitern.


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myTimerTask&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.jgeppert.timer.MyTimerTask&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;meinDAO&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;MeinDAO&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;scheduledTask&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.scheduling.timer.ScheduledTimerTask&quot;</span> <span style="color: #000066;">lazy-init</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #808080; font-style: italic;">&lt;!-- Die Startzeit nach der der TimerTask initial starten soll in Millisekunden --&gt;</span>
		<span style="color: #808080; font-style: italic;">&lt;!-- In diesem Beispiel also nach einer Minute --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;delay&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;60000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- Alle wieviel Millisekunden solle der Task wieder laufen --&gt;</span>
		<span style="color: #808080; font-style: italic;">&lt;!-- In diesem Beispiel läuft der Task alle 10 Minuten --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;period&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;600000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;timerTask&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;myTimerTask&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;timerFactory&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.scheduling.timer.TimerFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;scheduledTimerTasks&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	       		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;scheduledTask&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




So lässt sich also auf einfache Art und Weise ein Timer mit <a href="http://www.springframework.org/">Spring</a> ausführen. Mehr Informationen und komplexere Beispiele mit dem Quartz Scheduler findet ihr in der <a href="http://static.springframework.org/spring/docs/2.5.5/reference/scheduling.html">Dokumentation</a>.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/' addthis:title='Mit dem Spring Framework einen Scheduler ausführen ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/mit-dem-spring-framework-einen-scheduler-ausfuhren/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Iterieren mit Struts2</title>
		<link>http://www.jgeppert.com/2008/07/iterieren-mit-struts2/</link>
		<comments>http://www.jgeppert.com/2008/07/iterieren-mit-struts2/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 13:24:57 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[struts2]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[iterieren]]></category>
		<category><![CDATA[rowcolor]]></category>
		<category><![CDATA[rownumber]]></category>
		<category><![CDATA[rowstatus]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[zeilenfarbe]]></category>
		<category><![CDATA[zeilennummer]]></category>
		<category><![CDATA[zeilenstatus]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=108</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/iterieren-mit-struts2/' addthis:title='Iterieren mit Struts2 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Beim Lesen von Listen und Tabellen ist es praktisch, wenn jede Zeile eine andere Farbe hat und wenn man die aktuelle Zeilennummer ausgibt. Struts2 stellt uns dafür die Klasse IteratorStatus bereit. Mit Hilfe dieser Klasse können wir auf folgende Attribute zugreifen. IteratorStatus index: Die aktuelle Position in der Liste, beginnt mit 0 count: Ist immer [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/iterieren-mit-struts2/' addthis:title='Iterieren mit Struts2 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/iterieren-mit-struts2/' addthis:title='Iterieren mit Struts2 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Beim Lesen von Listen und Tabellen ist es praktisch, wenn jede Zeile eine andere Farbe hat und wenn man die aktuelle Zeilennummer ausgibt.

<a href="http://struts.apache.org/2.x/" target="_blank">Struts2</a> stellt uns dafür die Klasse <strong>IteratorStatus</strong> bereit. Mit Hilfe dieser Klasse können wir auf folgende Attribute zugreifen.

<strong>IteratorStatus</strong>
<ul>
	<li>index: Die aktuelle Position in der Liste, beginnt mit 0</li>
	<li>count: Ist immer index +1</li>
	<li>first: true wenn index == 0</li>
	<li>even: true wenn (index + 1) % 2 == 0</li>
	<li>last: true wenn die aktuelle iteration die letzte iteration ist</li>
	<li>odd: true wenn (index + 1) % 2 == 1</li>
</ul>

<p>
Der Code für die Klasse <em>Iterieren</em> ist recht einfach und besteht nur aus einer gefüllten Liste sowie deren Getter Methode.
</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.LinkedList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.struts2.config.Namespace</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.struts2.config.Result</span><span style="color: #339933;">;</span>
&nbsp;
@Result<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;pages/iterieren.jsp&quot;</span><span style="color: #009900;">&#41;</span>
@Namespace<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Iterieren <span style="color: #000000; font-weight: bold;">extends</span> BaseSupport <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 3577088331304224342L<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">List</span> liste<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
liste <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">LinkedList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Warren Buffett&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Carlos Slim Helu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;William Gates III&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Lakshmi Mittal&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mukesh Ambani&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Anil Ambani&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ingvar Kamprad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;KP Singh&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Oleg Deripaska&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Karl Albrecht&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Li Ka-shing&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Sheldon Adelson&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bernard Arnault&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Lawrence Ellison&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Roman Abramovich&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Theo Albrecht&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Liliane Bettencourt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Alexei Mordashov&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Prince Alwaleed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
liste.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mikhail Fridman&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> SUCCESS<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> getListe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> liste<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



<p>
In der JSP <em>iterieren.jsp</em> können wir jetzt mit dem Struts2 Tag  auf unsere Liste zugreifen.
Über den IteratorStatus der einzelnen Zeile können wir auf die aktuelle Position zugreifen sowie feststellen, ob die aktuelle Zeilennummer gerade ist.
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;%@ taglib <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;/struts-tags&quot;</span> %<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;text-align: center;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width: 450px; text-align:left;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;thead<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;color: #fff; width: 50px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Position<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;color: #fff; width: 300px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Milliard<span style="color: #ddbb00;">&amp;auml;</span>re<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/thead<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tbody<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:iterator</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;liste&quot;</span> <span style="color: #000066;">status</span>=<span style="color: #ff0000;">&quot;rowstatus&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:if</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;#rowstatus.odd == true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;background: aqua;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;s:property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;%{#rowstatus.count}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;background: aqua;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;s:property</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:else<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;background: blue;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;s:property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;%{#rowstatus.count}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;background: blue;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;s:property</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:else<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:iterator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>




<p>
Das Ergebnis gibt uns jetzt die Liste der 20 reichsten Personen aus.
</p>
<div id="attachment_113" class="wp-caption aligncenter" style="width: 470px"><a href="http://www.jgeppert.com/wp-content/uploads/struts2_iterieren1.jpg"><img class="size-full wp-image-113" title="Iterieren mit Struts2" src="http://www.jgeppert.com/wp-content/uploads/struts2_iterieren1.jpg" alt="Iterieren mit Struts2" width="460" height="366" /></a><p class="wp-caption-text">Iterieren mit Struts2</p></div> <div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/iterieren-mit-struts2/' addthis:title='Iterieren mit Struts2 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/iterieren-mit-struts2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SHA Checksum bilden</title>
		<link>http://www.jgeppert.com/2008/07/sha-checksum-bilden/</link>
		<comments>http://www.jgeppert.com/2008/07/sha-checksum-bilden/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 21:14:33 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[checksum]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[prüfsumme]]></category>
		<category><![CDATA[prüfsummen algorithmus]]></category>
		<category><![CDATA[secure]]></category>
		<category><![CDATA[sha]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=72</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/sha-checksum-bilden/' addthis:title='SHA Checksum bilden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Nach dem wir uns angesehen haben wie man eine MD5 Prüfsumme bildet, ist hier ein kleines Beispiel wie man eine SHA Checksum mit Java erstellt. SHA heißt Secure Hash Algorithm und ist ein weiteres Verfahren um eindeutige Prüfsummen zu erstellen. public static String getSHAString&#40;String s&#41; &#123; try &#123; MessageDigest sha = MessageDigest.getInstance&#40;&#34;SHA&#34;&#41;; StringBuffer t = [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/sha-checksum-bilden/' addthis:title='SHA Checksum bilden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/sha-checksum-bilden/' addthis:title='SHA Checksum bilden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Nach dem wir uns angesehen haben wie man eine <a title="MD5 Prüfsumme" href="http://www.jgeppert.com/?p=12">MD5 Prüfsumme</a> bildet, ist hier ein kleines Beispiel wie man eine SHA Checksum mit Java erstellt. SHA heißt Secure Hash Algorithm und ist ein weiteres Verfahren um eindeutige Prüfsummen zu erstellen.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getSHAString<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">MessageDigest</span> sha <span style="color: #339933;">=</span> <span style="color: #003399;">MessageDigest</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHA&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">StringBuffer</span> t <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> digest <span style="color: #339933;">=</span> sha.<span style="color: #006633;">digest</span><span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span> b <span style="color: #339933;">:</span> digest<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%02x&quot;</span>, b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> val <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> 0xff<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span> t.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
t.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">toHexString</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> t.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/sha-checksum-bilden/' addthis:title='SHA Checksum bilden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/sha-checksum-bilden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mit Java eine SAP Funktion aufrufen</title>
		<link>http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/</link>
		<comments>http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 10:22:46 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[sap]]></category>
		<category><![CDATA[aufrufen]]></category>
		<category><![CDATA[ausführen]]></category>
		<category><![CDATA[funktion]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[sapjco]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=54</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/' addthis:title='Mit Java eine SAP Funktion aufrufen '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um mit Java eine Remote fähige Funktion aus einem SAP System aufzurufen. müsst Ihr euch den sapjco Connector von SAP herunterladen. Die Datei sapjco.jar muss in eurern CLASSPATH, also bei einer Webanwendung ins WEB-INF/lib Verzeichniss. Die System abhängigen Dateien, sapjcorfc.dll und librfc32.dll unter Windows, und libsapjcorfc.so und librfccm.so unter Linux müssen in eurem PATH verfügbar [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/' addthis:title='Mit Java eine SAP Funktion aufrufen ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/' addthis:title='Mit Java eine SAP Funktion aufrufen '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um mit Java eine Remote fähige Funktion aus einem SAP System aufzurufen. müsst Ihr euch den sapjco Connector von SAP herunterladen.

Die Datei <em>sapjco.jar</em> muss in eurern <strong>CLASSPATH</strong>, also bei einer Webanwendung ins WEB-INF/lib Verzeichniss.

Die System abhängigen Dateien, <em>sapjcorfc.dll</em> und <em>librfc32.dll</em> unter Windows, und <em>libsapjcorfc.so</em> und <em>librfccm.so</em> unter Linux müssen in eurem <strong>PATH</strong> verfügbar sein.

Als nächstes könnt erstellt Ihr eine Klasse SAPConnect, von dieser Klasse lasst Ihr alle Klassen erben die eine Verbindung zu SAP aufbauen wollen.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sap.mw.jco.IFunctionTemplate</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sap.mw.jco.JCO</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SAPConnect <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">private</span> JCO.<span style="color: #006633;">Client</span>     mConnection<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> JCO.<span style="color: #003399;">Repository</span> mRepository<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>         userid<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>         password<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>         mandant<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>         appServer<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>         systemNumber<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span>        connected <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">protected</span> SAPConnect<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> user, <span style="color: #003399;">String</span> password, <span style="color: #003399;">String</span> mand, <span style="color: #003399;">String</span> server, <span style="color: #003399;">String</span> number<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userid</span> <span style="color: #339933;">=</span> user<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">password</span> <span style="color: #339933;">=</span> password<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mandant</span> <span style="color: #339933;">=</span> mand<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">appServer</span> <span style="color: #339933;">=</span> server<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">systemNumber</span> <span style="color: #339933;">=</span> number<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> connect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
mConnection <span style="color: #339933;">=</span> JCO.<span style="color: #006633;">createClient</span><span style="color: #009900;">&#40;</span>mandant, userid, password, <span style="color: #0000ff;">&quot;DE&quot;</span>, appServer, systemNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mConnection.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mRepository <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JCO.<span style="color: #003399;">Repository</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MyRepository&quot;</span>, mConnection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
connected <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">protected</span> JCO.<span style="color: #006633;">Function</span> execute<span style="color: #009900;">&#40;</span>JCO.<span style="color: #006633;">Function</span> function<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
mConnection.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>function <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>function.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; nicht im SAP gefunden.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">return</span> function<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> disconnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
mConnection.<span style="color: #006633;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
connected <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">protected</span> JCO.<span style="color: #006633;">Function</span> createFunction<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
IFunctionTemplate ft <span style="color: #339933;">=</span> mRepository.<span style="color: #006633;">getFunctionTemplate</span><span style="color: #009900;">&#40;</span>name.<span style="color: #006633;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ft <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> ft.<span style="color: #006633;">getFunction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Exception</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Problem beim erstellen des JCO.Function Objects.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> JCO.<span style="color: #003399;">Repository</span> getRepository<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> mRepository<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isConnected<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> connected<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



In diesem Beispiel wollen wir die Funktion <strong>TH_WPINFO</strong> aufrufen die uns alle aktuellen Prozesse im SAP zurückliefert.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sap.mw.jco.JCO</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">de.esag.utils.SAPConnect</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Prozesse <span style="color: #000000; font-weight: bold;">extends</span> SAPConnect
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> Prozesse<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userid, <span style="color: #003399;">String</span> password, <span style="color: #003399;">String</span> Mandant, <span style="color: #003399;">String</span> AppServer, <span style="color: #003399;">String</span> SystemNumber<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>userid,password,Mandant,AppServer,SystemNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
connect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
JCO.<span style="color: #006633;">Function</span> function <span style="color: #339933;">=</span> createFunction<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TH_WPINFO&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
execute<span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
JCO.<span style="color: #006633;">Table</span> codes <span style="color: #339933;">=</span> function.<span style="color: #006633;">getTableParameterList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WPLIST&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> codes.<span style="color: #006633;">getNumRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
codes.<span style="color: #006633;">setRow</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_NO&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_PID&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_BNAME&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_REPORT&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_STATUS&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_ELTIME&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_TYP&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>codes.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WP_MANDT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
disconnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">new</span> Prozesse<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;benutzer&quot;</span>,<span style="color: #0000ff;">&quot;passwort&quot;</span>,<span style="color: #0000ff;">&quot;mandant&quot;</span>,<span style="color: #0000ff;">&quot;server&quot;</span>,<span style="color: #0000ff;">&quot;systemnummer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



Beim ausführen der Klasse solltet Ihr jetzt alle laufenden Prozesse eures SAP Systemes sehen.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/' addthis:title='Mit Java eine SAP Funktion aufrufen ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/mit-java-eine-sap-funktion-aufrufen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Mass JPEG Resizer Tool</title>
		<link>http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/</link>
		<comments>http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 21:07:12 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[projekte]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[bilder]]></category>
		<category><![CDATA[gallerie]]></category>
		<category><![CDATA[gallerien]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[nassenverarbeitung]]></category>
		<category><![CDATA[verkleinern]]></category>
		<category><![CDATA[web gallerie]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=29</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/' addthis:title='Java Mass JPEG Resizer Tool '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Ein Tool zur Massenbearbeitung von Bildern. Das Tool hat folgende Features: Ein einzelnes Bild oder mehrere Bilder gleichzeitig auf eine bestimmte Größe ändern Für E-Mail Anhänge können diese Bilder automatisch gezippt werde Erstellen von Webgallerien Mehrsprachig ( Deutsch und English ) Das Programm basiert auf Java und läuft somit unter allen gängigen Betriebssystemen wie Linux, [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/' addthis:title='Java Mass JPEG Resizer Tool ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/' addthis:title='Java Mass JPEG Resizer Tool '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><span>Ein Tool zur Massenbearbeitung von Bildern.</span>

<span>Das Tool hat folgende Features:</span>
<ul>
	<li>Ein einzelnes Bild oder mehrere Bilder gleichzeitig auf eine bestimmte Größe ändern</li>
	<li>Für E-Mail Anhänge können diese Bilder automatisch gezippt werde</li>
	<li>Erstellen von Webgallerien</li>
	<li>Mehrsprachig ( Deutsch und English )</li>
	<li>Das Programm basiert auf Java und läuft somit unter allen gängigen Betriebssystemen wie Linux, MacOS, Windows und diversen Unix Betriebssystemen</li>
</ul>
<span>Das Tool ist OpenSource und kann bei <a href="http://jmjrst.sourceforge.net/">Sourceforge</a> heruntergeladen werden.</span>

<a href="http://www.jgeppert.com/wp-content/uploads/jmjrst.jpg"><img class="alignnone size-medium wp-image-30" title="jmjrst" src="http://www.jgeppert.com/wp-content/uploads/jmjrst.jpg" alt="" width="250" height="187" /></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/' addthis:title='Java Mass JPEG Resizer Tool ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/java-mass-jpeg-resizer-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kaskade</title>
		<link>http://www.jgeppert.com/2008/07/kaskade/</link>
		<comments>http://www.jgeppert.com/2008/07/kaskade/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 20:11:50 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[projekte]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[kaskade]]></category>
		<category><![CDATA[programmierpraktikum]]></category>
		<category><![CDATA[spiel]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=32</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/kaskade/' addthis:title='Kaskade '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Eine Brettspielumsetzung die ich im Rahmen meines Programmierpraktikums an der Fernuni Hagen mit Java programmiert habe. Ziel des Spieles ist es durch überläufe eines eigenen Feldes gegnerische Felder zu übernehmen. Jedes Feld kann maximal soviele Steine aufnehmen wie es Nachbarfelder hat. Wenn ein Feld voll ist werden die Steine auf die umliegenden Felder verteilt und [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/kaskade/' addthis:title='Kaskade ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/kaskade/' addthis:title='Kaskade '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><span>Eine Brettspielumsetzung die ich im Rahmen meines Programmierpraktikums an der Fernuni Hagen mit Java programmiert habe.</span>

<span>Ziel des Spieles ist es durch überläufe eines eigenen Feldes gegnerische Felder zu übernehmen. Jedes Feld kann maximal soviele Steine aufnehmen wie es Nachbarfelder hat. Wenn ein Feld voll ist werden die Steine auf die umliegenden Felder verteilt und übernommen. Leider war für eine wirklich starke Computer Engine am Ende doch keine Zeit mehr, aber ich hoffe Ihr habt trotzdem Spaß. </span>

<a href="http://www.jgeppert.com/wp-content/uploads/kaskade.jar">Hier könnt Ihr das Spiel herunterladen und testen.</a>

<span>Das Spiel kann mit <code>java -jar kaskade.jar</code> gestarted werden. Die empfohlene Java Version ist JRE5.</span>

<a href="http://www.jgeppert.com/wp-content/uploads/kaskade.jpg"><img class="alignnone size-full wp-image-34" title="kaskade" src="http://www.jgeppert.com/wp-content/uploads/kaskade.jpg" alt="" width="300" height="300" /></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/kaskade/' addthis:title='Kaskade ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/kaskade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Einstellungen wieder laden</title>
		<link>http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/</link>
		<comments>http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 19:38:25 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[laden]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[properties]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=16</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/' addthis:title='Java Einstellungen wieder laden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um mit Java ein gespeichert Einstellungen wieder zu laden verwendet folgenden Code. try &#123; File f = new File&#40;&#34;options.properties&#34;&#41;; Properties p = new Properties&#40;&#41;; p.loadFromXML&#40;new FileInputStream&#40;f&#41;&#41;; &#160; port = p.getProperty&#40;&#34;port&#34;&#41;; host = p.getProperty&#40;&#34;host&#34;&#41;; &#125; catch &#40;Exception e&#41; &#123; System.out.println&#40;&#34;No options found, using default!&#34;&#41;; &#125;<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/' addthis:title='Java Einstellungen wieder laden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/' addthis:title='Java Einstellungen wieder laden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um mit Java ein gespeichert Einstellungen wieder zu laden verwendet folgenden Code.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;options.properties&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Properties</span> p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
p.<span style="color: #006633;">loadFromXML</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileInputStream</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
port <span style="color: #339933;">=</span> p.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;port&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
host <span style="color: #339933;">=</span> p.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No options found, using default!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/' addthis:title='Java Einstellungen wieder laden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/java-einstellungen-wieder-laden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Einstellungen speichern</title>
		<link>http://www.jgeppert.com/2008/07/java-einstellungen-speichern/</link>
		<comments>http://www.jgeppert.com/2008/07/java-einstellungen-speichern/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 19:35:53 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[speichern]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=14</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-speichern/' addthis:title='Java Einstellungen speichern '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um in Java Einstellungen zu speichern, um zum Beispiel eine Konfiguration zu sichern, könnt Ihr wie folgt vorgehen. File f = new File&#40;&#34;options.properties&#34;&#41;; Properties p = new Properties&#40;&#41;; &#160; p.setProperty&#40;&#34;port&#34;, &#34;8080&#34;&#41;; p.setProperty&#40;&#34;host&#34;, &#34;localhost&#34;&#41;; &#160; p.storeToXML&#40;new FileOutputStream&#40;f&#41;, new Date&#40;System.currentTimeMillis&#40;&#41;&#41;.toString&#40;&#41;&#41;;<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-speichern/' addthis:title='Java Einstellungen speichern ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-speichern/' addthis:title='Java Einstellungen speichern '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um in Java Einstellungen zu speichern, um zum Beispiel eine Konfiguration zu sichern, könnt Ihr wie folgt vorgehen.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;options.properties&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Properties</span> p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
p.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;port&quot;</span>, <span style="color: #0000ff;">&quot;8080&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
p.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;host&quot;</span>, <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
p.<span style="color: #006633;">storeToXML</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/java-einstellungen-speichern/' addthis:title='Java Einstellungen speichern ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/java-einstellungen-speichern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MD5 Checksum bilden</title>
		<link>http://www.jgeppert.com/2008/07/md5-checksum-bilden/</link>
		<comments>http://www.jgeppert.com/2008/07/md5-checksum-bilden/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 19:31:19 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[checksum]]></category>
		<category><![CDATA[md5]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=12</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/md5-checksum-bilden/' addthis:title='MD5 Checksum bilden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um mit Java eine MD5 Checksum zu bilden, zum Beispiel um ein Passwort nicht in klartext in der Datenbank zu speichern, könnt ihr folgenden Code verwenden. import java.security.MessageDigest; &#160; MessageDigest md = MessageDigest.getInstance&#40;&#34;MD5&#34;&#41;; char&#91;&#93; charArray = input.toCharArray&#40;&#41;; &#160; byte&#91;&#93; byteArray = new byte&#91;charArray.length&#93;; &#160; for &#40;int i = 0; i &#38;lt; charArray.length; i++&#41; byteArray&#91;i&#93; = [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/md5-checksum-bilden/' addthis:title='MD5 Checksum bilden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/md5-checksum-bilden/' addthis:title='MD5 Checksum bilden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um mit Java eine MD5 Checksum zu bilden, zum Beispiel um ein Passwort nicht in klartext in der Datenbank zu speichern, könnt ihr folgenden Code verwenden.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.security.MessageDigest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">MessageDigest</span> md <span style="color: #339933;">=</span> <span style="color: #003399;">MessageDigest</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MD5&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> charArray <span style="color: #339933;">=</span> input.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> byteArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span>charArray.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> charArray.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
byteArray<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#41;</span> charArray<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> md5Bytes <span style="color: #339933;">=</span> md.<span style="color: #006633;">digest</span><span style="color: #009900;">&#40;</span>byteArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">StringBuffer</span> hexValue <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> md5Bytes.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">int</span> val <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> md5Bytes<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> 0xff<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span> hexValue.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
hexValue.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">toHexString</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>code<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #003399;">String</span> md5 <span style="color: #339933;">=</span> hexValue.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/md5-checksum-bilden/' addthis:title='MD5 Checksum bilden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/md5-checksum-bilden/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mit Java eine E-Mail versenden</title>
		<link>http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/</link>
		<comments>http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 19:27:32 +0000</pubDate>
		<dc:creator>jogep</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[e-mail]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[javamail]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[versenden]]></category>

		<guid isPermaLink="false">http://www.jgeppert.com/?p=10</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/' addthis:title='Mit Java eine E-Mail versenden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Um eine Mail mit Java zu versenden einfach folgenden Code verwenden, Ihr müsst nur noch eure Mailserver Daten ersetzen. 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; &#160; String smtpHost = &#34;smtp.deinhost.de&#34;; Properties props = new Properties&#40;&#41;; props.put&#40;&#34;mail.smtp.host&#34;, smtpHost&#41;; Session session = Session.getDefaultInstance&#40;props, null&#41;; &#160; MimeMessage msg = new MimeMessage&#40;session&#41;; &#160; [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/' addthis:title='Mit Java eine E-Mail versenden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/' addthis:title='Mit Java eine E-Mail versenden '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><span>Um eine Mail mit Java zu versenden einfach folgenden Code verwenden, Ihr müsst nur noch eure Mailserver Daten ersetzen.
</span>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.mail.Message</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.mail.MessagingException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.mail.Session</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.mail.Transport</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.mail.internet.InternetAddress</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.mail.internet.MimeMessage</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">String</span> smtpHost <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;smtp.deinhost.de&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Properties</span> props <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
props.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mail.smtp.host&quot;</span>, smtpHost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Session session <span style="color: #339933;">=</span> Session.<span style="color: #006633;">getDefaultInstance</span><span style="color: #009900;">&#40;</span>props, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MimeMessage msg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MimeMessage<span style="color: #009900;">&#40;</span>session<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
InternetAddress addressFrom <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> InternetAddress<span style="color: #009900;">&#40;</span>from<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
msg.<span style="color: #006633;">setFrom</span><span style="color: #009900;">&#40;</span>addressFrom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
InternetAddress addressTo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> InternetAddress<span style="color: #009900;">&#40;</span>recipient<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
msg.<span style="color: #006633;">addRecipient</span><span style="color: #009900;">&#40;</span>Message.<span style="color: #006633;">RecipientType</span>.<span style="color: #006633;">TO</span>, <span style="color: #0000ff;">&quot;dort@solleshin.de&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
msg.<span style="color: #006633;">setSubject</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
msg.<span style="color: #006633;">setContent</span><span style="color: #009900;">&#40;</span>message, <span style="color: #0000ff;">&quot;text/html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
msg.<span style="color: #006633;">saveChanges</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Transport transport <span style="color: #339933;">=</span> session.<span style="color: #006633;">getTransport</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;smtp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
transport.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>smtpHost, <span style="color: #0000ff;">&quot;account&quot;</span>, <span style="color: #0000ff;">&quot;passwort&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
transport.<span style="color: #006633;">sendMessage</span><span style="color: #009900;">&#40;</span>msg, msg.<span style="color: #006633;">getAllRecipients</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
transport.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/' addthis:title='Mit Java eine E-Mail versenden ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.jgeppert.com/2008/07/mit-java-eine-e-mail-versenden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

