[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

struts login example issue

Asked by gudii9 in Jakarta Struts, J2EE, Java Programming Language

Hi,

I am trying to run a struts 1.1 login example in RAD 7.0 within websphere 6.1 server. My code looks as follows. It has simple form, action, three simple jsps and a validation. When i try to run it giving error saying 'unable to locate tag library tags-html as in attachment




ApplicationResources.properties looks like





# Resources for parameter 'com.myeclipseide.example.struts.ApplicationResources'
# Project StrutsLoginExample
error.name.required=User Name Required
error.password.required=Password Required
error.name.myeclipse=Please enter MyEclipse1 as the User Name
error.password.myeclipse=Please enter MyEclipse2 as the Password


index.jsp looks like

<%@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>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>MyEclipse Struts Login Example</title>
    </head>
    <body>
        <h1>
            MyEclipse Struts Login Example Project
        </h1>
        <div
            style="padding-left: 5px; padding-top: 10px; padding-bottom: 10px; background: #f0f0f0">
            <b><a href="userLogin.jsp">Click here</a> to begin testing this
                example</b>
        </div>
        <h2>
            Description
        </h2>

        A tutorial showing how to develop a simple login-style Struts application.
       
               <br>
        <h2>
            Requirements
        </h2>
        MyEclipse 6.0 or a previous version of MyEclipse with an application
        server that the project can be deployed to and run.
        <h2>
            How to Run
        </h2>

            You can right-click on this project and go to Debug As or Run As then select
            "MyEclipse Server Application". MyEclipse 6.0 and later will automatically deploy
            the application to the MyEclipse Tomcat Server, then start it up and open
            a browser window for you to the index.jsp page.
        <br>
        <h2>
            Related Links
        </h2>
        <ul>
            <li>

                MyEclipse Web Project Tutorial -
                <a href="http://www.myeclipseide.com/documentation/quickstarts/webprojects/">http://www.myeclipseide.com/documentation/quickstarts/webprojects/</a>
            </li>
            <li>
                MyEclipse Application Server Tutorial -
                <a href="http://www.myeclipseide.com/documentation/quickstarts/appservers/">http://www.myeclipseide.com/documentation/quickstarts/appservers/</a>
            </li>
            <li>
                MyEclipse Struts 1.x Tutorial -
                <a href="http://www.myeclipseide.com/documentation/quickstarts/struts/">http://www.myeclipseide.com/documentation/quickstarts/struts/</a>
            </li>
        </ul>
        <h2>
            Feedback
        </h2>

        We hope you found this example project helpful. If you ran into any
        problems
        <br>
        while working with the example project, please feel free to post to
        our Example
        <br>
        Project Forum (
        <a href="http://www.myeclipseide.com/PNphpBB2-viewforum-f-54.html">http://www.myeclipseide.com/PNphpBB2-viewforum-f-54.html</a>)
        and
        <br>
        let us know. Also if you had any suggestions for improvements, noticed
        something
        <br>
        wrong or just wanted to ask questions we encourage you to post and let
        us know!
    </body>
</html>




userLogin.jsp looks like




<%@ page language="java" pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
      <html:base />

      <title>JSP for UserLoginForm form</title>

      <meta http-equiv="pragma" content="no-cache">
      <meta http-equiv="cache-control" content="no-cache">
      <meta http-equiv="expires" content="0">
      <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
      <meta http-equiv="description" content="This is my page">
      <!--
      <link rel="stylesheet" type="text/css" href="styles.css">
      -->
</head>
<body>
      <html:form action="/userLogin">
            <table border="1" cellpadding="4">
                  <tbody>
                        <tr>
                              <td align="right">
                                    User Name:
                              </td>
                              <td>
                                    <html:text property="userName" />
                              </td>
                              <td>
                                    <html:errors property="userName" />
                              </td>
                        </tr>
                        <tr>
                              <td align="right">
                                    Password:
                              </td>
                              <td>
                                    <html:password property="password" />
                              </td>
                              <td>
                                    <html:errors property="password" />
                              </td>
                        </tr>
                        <tr>
                              <td>
                                    &nbsp;
                              </td>
                              <td>
                                    <html:submit />
                                    <html:cancel />
                              </td>
                        </tr>
                  </tbody>
            </table>
      </html:form>
</body>
</html:html>



userLoginSuccess looks like

<%@ page language="java" pageEncoding="ISO-8859-1"%>

<%@ 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" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
  <head>
    <title>My Struts 'userLoginSuccess.jsp' ending page</title>
  </head>
 
  <body>
    Hello <bean:write name="userName" scope="request" />, you successfully logged in!
  </body>
</html:html>




struts-config looks like




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
      <form-beans>
            <form-bean name="userLoginForm"
                  type="com.myeclipseide.examples.struts.form.UserLoginForm" />
      </form-beans>
      <global-exceptions />
      <global-forwards />
      <action-mappings>
            <action attribute="userLoginForm" input="/userLogin.jsp"
                  name="userLoginForm" path="/userLogin" scope="request"
                  validate="true"
                  type="com.myeclipseide.examples.struts.action.UserLoginAction">
                  <forward name="success" path="/userLoginSuccess.jsp" />
                  <forward name="failure" path="/userLogin.jsp" />
            </action>
      </action-mappings>
      <message-resources
            parameter="com.myeclipseide.examples.struts.ApplicationResources" />
</struts-config>



web.xml looks like

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <servlet>
            <servlet-name>action</servlet-name>
            <servlet-class>
                  org.apache.struts.action.ActionServlet
            </servlet-class>
            <init-param>
                  <param-name>config</param-name>
                  <param-value>/WEB-INF/struts-config.xml</param-value>
            </init-param>
            <init-param>
                  <param-name>debug</param-name>
                  <param-value>3</param-value>
            </init-param>
            <init-param>
                  <param-name>detail</param-name>
                  <param-value>3</param-value>
            </init-param>
            <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
            <servlet-name>action</servlet-name>
            <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
</web-app>



UserLoginAction looks like





package com.myeclipseide.examples.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.myeclipseide.examples.struts.form.UserLoginForm;

public class UserLoginAction extends Action {
      @Override
      public ActionForward execute(ActionMapping mapping, ActionForm form,
                  HttpServletRequest request, HttpServletResponse response) {
            UserLoginForm userLoginForm = (UserLoginForm) form;

            if (userLoginForm.getUserName().equalsIgnoreCase("myeclipse1")
                        && userLoginForm.getPassword().equalsIgnoreCase("myeclipse2")) {
                  request.setAttribute("userName", userLoginForm.getUserName());
                  return mapping.findForward("success");
            }

            return mapping.findForward("failure");

      }
}



userLoginForm looks like





package com.myeclipseide.examples.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class UserLoginForm extends ActionForm {
      private static final long serialVersionUID = 1L;

      private String password;

      private String userName;

      @Override
      public ActionErrors validate(ActionMapping mapping,
                  HttpServletRequest request) {

            ActionErrors errors = new ActionErrors();

            if (getUserName() == null || getUserName().length() < 1) {
                  errors.add("userName", new ActionMessage("error.name.required"));
            } else if (!getUserName().equalsIgnoreCase("myeclipse1")) {
                  errors.add("userName", new ActionMessage("error.name.myeclipse1"));
            }
            if (getPassword() == null || getPassword().length() < 1) {
                  errors
                              .add("password", new ActionMessage(
                                          "error.password.required"));
            } else if (!getPassword().equalsIgnoreCase("myeclipse2")) {
                  errors.add("password",
                              new ActionMessage("error.password.myeclipse2"));
            }

            return errors;

      }

      @Override
      public void reset(ActionMapping mapping, HttpServletRequest request) {
            password = null;
            userName = null;
      }

      public String getPassword() {
            return password;
      }

      public void setPassword(String password) {
            this.password = password;
      }

      public String getUserName() {
            return userName;
      }

      public void setUserName(String userName) {
            this.userName = userName;
      }
}



Any ideas, suggestions, sample code, links highly appreciated. Thanks in advance.
Attachments:
 
error message
error message
 
 
Loading Advertisement...
 
[+][-]08/26/09 06:37 PM, ID: 25193881Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Jakarta Struts, J2EE, Java Programming Language
Sign Up Now!
Solution Provided By: sanjooz
Participating Experts: 1
Solution Grade: A
 
[+][-]08/27/09 09:39 AM, ID: 25200172Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/27/09 11:15 AM, ID: 25201088Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625