Search code examples
javajspservletsstrutsstruts-tags

How to configure the path of files inside a folder in Struts config file


I created a folder named customer and I placed the following JSP files inside it edit.jsp, editsuccess.jsp.

My struts config is

<action input="/customer/edit.jsp" name="Edit" path="/edit" scope="request"  type="Controller.Editctr">
   <forward name="success" path="/customer/editsuccess.jsp"/>
</action>

In this edit.jsp is input page and editsuccess.jsp is the output page for the controller (Servlet) named Editctr and a path of the controller is edit. Here I am calling the servlet in the front end through JSP

<form action="edit.do" method="post">

When I submit the form it shows the following error

HTTP Status 404 - Invalid path was requested

I tried some possible ways of changing but still I couldn't able to fix it.


Solution

  • If you are using html form tag then you should map the action properly.

    <form action="${pageContext.request.contextpath}/edit.do" method="post">
    

    or use html taglib

    <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
    
    <html:form action="/edit" method="post">