0 Replies - 654 Views - Last Post: 13 May 2017 - 08:10 AM

#1 Catalinaeva1   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 13-May 17

Help Creating a Simple Login Page Using Eclipse/Maven

Posted 13 May 2017 - 08:10 AM


Sorry to bother everyone, but I'm new to using Java with Eclipse. I'm working with struts in Maven, and I'm trying to create a simple login page where a user enters his/her username and password; then when he/she hits the submit or login button, it redirects them to another page (e.g. welcome page). I'm having trouble getting this to happen because when I run the code in Apache server using Tomcat 7, I keep getting a 404 error saying "There is no action mapped for namespace [/] and action named [Welcome] associated with context path [/myapp]. I read that this has to do with my path being incorrect in the struts.xml file. Can anyone help me fix my code since I'm super new to struts and have been searching tutorials to help me out. I've also attached the zip file.

Here's my code below:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0/>/>.xsd">
  <name>myapp Maven Webapp</name>



package com.test;

public class LoginAction {

	private String username;
	private String password;

	public String getUsername() {
		return username;
	public String getPassword(){
		return password;

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

	// all struts logic here
	public String execute() {

		return "SUCCESS";



<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
	<h1>Employee Login Page</h1>

	<s:form action="Welcome">
		<s:textfield name="username" label="Username" />
		<s:password name="password" label="Password" />
		<s:submit />



<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


	<package name="default" namespace="/" extends="struts-default">
		<action name="Login">
		<action name="Welcome" class="com.test.LoginAction">
			<result name="SUCCESS">/welcome_user.jsp</result>



 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

	<display-name>Struts 2 Web Application</display-name>



Any help is appreciated.

Is This A Good Question/Topic? 1
  • +

Page 1 of 1