Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with Struts Action mapping
    text
    copied!<p>I am having a problem with my struts application it is a class enrollment app and when the user clicks on a "show enrolled courses" button it is supposed to show the courses they are enrolled in but it shows nothing at the moment. Struts/Apache does not return any errors, it Just shows a blank page and I cannot figure out why.</p> <p>My action mapping in my struts-config:</p> <pre><code> &lt;action path="/showEnrolled" type="actions.ShowEnrolledAction" name="UserFormEnrolled" scope="request" validate="true" input="/students/StudentMenu.jsp"&gt; &lt;forward name="success" path="/students/enrolled.jsp"/&gt; &lt;/action&gt; </code></pre> <p>My link to the jsp enrolled.jsp page:</p> <pre><code>&lt;li&gt;&lt;html:form action="/showEnrolled"&gt; &lt;html:hidden property="id" value= "&lt;%=request.getRemoteUser()%&gt;"/&gt; &lt;html:submit value = "View Enrolled Classes"/&gt; &lt;/html:form&gt; &lt;/li&gt; </code></pre> <p>When I click the link I get nothing but my menu on the page. The text headings for the page are not even displayed.</p> <p>enrolled.jsp:</p> <pre><code>&lt;%@ page import="javax.sql.*"%&gt; &lt;%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%&gt; &lt;%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%&gt; &lt;html:html&gt; &lt;head&gt; &lt;title&gt;&lt;bean:message key="app.title" /&gt;&lt;/title&gt; &lt;html:base /&gt; &lt;/head&gt; &lt;body&gt; &lt;html:errors /&gt; &lt;h1&gt;Enrolled Courses for &lt;%=request.getRemoteUser() %&gt;&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;td valign="top"&gt; &lt;jsp:include page="/students/StudentMenu.jsp"/&gt; &lt;/td&gt; &lt;td&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Course Title&lt;/th&gt; &lt;th&gt;Course ID&lt;/th&gt; &lt;th&gt;Class ID&lt;/th&gt; &lt;th&gt;Days&lt;/th&gt; &lt;th&gt;Start Time&lt;/th&gt; &lt;th&gt;End Time&lt;/th&gt; &lt;th&gt;Location&lt;/th&gt; &lt;th&gt;Instructor&lt;/th&gt; &lt;/tr&gt; &lt;%-- -------- Iteration Code -------- --%&gt; &lt;% // Get the studentsRowSet RowSet crsEnrolled = (RowSet) request.getAttribute("crsEnrolled"); // Iterate over the RowSet while (crsEnrolled.next()) { %&gt; &lt;tr&gt; &lt;html:form action="/dropClass"&gt; &lt;td&gt; &lt;input type="hidden" name="title" value="&lt;%=crsEnrolled.getString("title") %&gt;" /&gt; &lt;%=crsEnrolled.getString("title") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="courseid" value="&lt;%=crsEnrolled.getInt("course_number") %&gt;" /&gt; &lt;%=crsEnrolled.getInt("course_id") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="classid" value="&lt;%=crsEnrolled.getInt("class_id") %&gt;" /&gt; &lt;%=crsEnrolled.getInt("class_id") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="days" value="&lt;%=crsEnrolled.getString("date_code") %&gt;" /&gt; &lt;%=crsEnrolled.getString("date_code") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="start" value="&lt;%=crsEnrolled.getTime("start_time") %&gt;" /&gt; &lt;%=crsEnrolled.getTime("start_time") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="end" value="&lt;%=crsEnrolled.getTime("end_time") %&gt;" /&gt; &lt;%=crsEnrolled.getTime("end_time") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="location" value="&lt;%=crsEnrolled.getString("cl_location") %&gt;" /&gt; &lt;%=crsEnrolled.getString("cl_location") %&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="instructorfirst" value="&lt;%=crsEnrolled.getString("first_name") %&gt;" /&gt; &lt;%=crsEnrolled.getString("first_name") %&gt; &lt;input type="hidden" name="instructorlast" value="&lt;%=crsEnrolled.getString("instructor_last") %&gt;" /&gt; &lt;%=crsEnrolled.getString("last_name") %&gt; &lt;/td&gt; &lt;html:hidden property="classId" value="&lt;%=Integer.toString(crsEnrolled.getInt("class_id"))%&gt;" /&gt; &lt;html:hidden property="stuId" value="&lt;%=request.getRemoteUser() %&gt;" /&gt; &lt;td&gt;&lt;html:submit value ="Drop" /&gt;&lt;/td&gt; &lt;/html:form&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html:html&gt; </code></pre> <p>ShowEnrolledAction:</p> <pre><code>package actions; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.sql.RowSet; import model.EnrollModel; 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 db.DbException; import forms.UserFormEnrolled; public class ShowEnrolledAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws DbException { // Cast the form UserFormEnrolled iForm = (UserFormEnrolled) form; iForm.setStudentId(request.getRemoteUser()); // Insert the student RowSet crsEnrolled = EnrollModel.getEnrolledClasses(iForm); request.setAttribute("crsEnrolled", crsEnrolled); return mapping.findForward("success"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload