Monday, January 16, 2006

Struts

We have our first webapp, now we can include struts, this is as easy as download it from the struts website, unpack the jar file.
Now look in eclipse and import in your webapp the struts-blanc jar file.
Now open your project on the server and you should see a nice welcome page from struts.

This example from struts looks easy, but actually there is a full flow exposed.
Here is the past of the code for this flow.
The files are bold, the code in that file is italic

index.jsp
<logic:redirect forward="welcome">
WEB-INF/struts-config.xml
<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards>
<forward path="/Welcome.do" name="welcome">
</GLOBAL-FORWARDS>

The Welcome.do means do action welcome later in that file
<action
path="/Welcome"
forward="/pages/Welcome.jsp"/>

So, the website starts with index.jsp and automatically loads pages/Welcome.jsp which is the page you seen when you opened your webapp.

This is not a full manual for struts, this is not my intention, I just want to give a small presentation how I set it up and more focus on the errors I have had and hopefully solved.

Should you have a question, please do not hesitate to contact me.

No comments: