17 to 20: Java Learning: Struts – a rant

I have lost in Java's servlet. There are so many things to learn and I do not have good books. SL 314 book is not enough for me. That have some theory part but not good in practical. Also Java strict typing is creating problem. Everything is object is also a big trouble for me.

I have lost the sequence because I have not posted many posts due to time. After 16th hour, I got some dose of Struts, and few basic Actions in Struts.

struts-workflow

Pic from netbeans

First App:

Page: WelcomeStruts.jsp


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<html:html lang="true">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><bean:message key="welcome.title"/></title>
        <html:base/>
    </head>
    <body style="background-color: white">
        <logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
            <div  style="color: red">
                ERROR:  Application resources not loaded -- check servlet container
                logs for error messages.
            </div>
        </logic:notPresent>
        <h3><bean:message key="welcome.heading"/></h3>
        <p><bean:message key="welcome.message"/></p>
        <html:link page="/First.do">First Page</html:link>
    </body>
</html:html>

Page:First.jsp


<%--
    Document   : First
    Created on : Oct 14, 2010, 10:32:59 PM
    Author     : satya
--%>
<%@taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html:html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        First page
        <hr>
        <html:link page="/Welcome.do">Go to Welcome</html:link>
    </body>
</html:html>

Page:struts-config.xml


<action-mappings>
        <action path="/Welcome" forward="/welcomeStruts.jsp"/>
        <action path="/First" forward="/First.jsp" />
    </action-mappings>

Action-mappings node was there. I have added action path=/First.jsp.

Output:

http://netbeans.org/kb/65/web/quickstart-webapps-struts.html

  • # 1 - by Convert To CSV

    I’ve been reading about this on a couple of other web sites, but you without a doubt expained this perfectly. Thanks a ton!

Comments are open for an year period. Please, write here on Facebook page.