Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

JSTL

Name: OP 2011-05-12 22:01

I can't figure this out. It was working before, now whenever my first JSP forwards to the 2nd one to do the insert, I get a 500 error.

JSP1:
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>jsp1</title>
  </head>
  <body>
 
    <!-- Session vars -->
    <c:set var="cID" value="${param.cID}" scope="session" />
    <c:set var="desc" value="${param.cDesc}" scope="session" />
    <c:set var="credits" value="${param.credits}" scope="session" />

    <sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbc:odbc:registrar" scope="session" />

    <sql:query var="query">
        SELECT count(*) FROM courses WHERE course like ?;
        <sql:param value="${param.cID}" />
    </sql:query>

    <c:choose>
        <c:when test="${empty param.cID || empty param.cDesc}">
            <!-- Empty field, send to jsp3 -->
            <jsp:forward page="jsp3.jsp"/>
        </c:when>
        <c:otherwise>
            <c:choose>
                <c:when test="${query.rowsByIndex[0][0] >= 1}">
                    <!-- Dupe, send to jsp3 -->
                    <jsp:forward page="jsp3.jsp"/>
                </c:when>
                <c:otherwise>
                    <!-- No empty field or dupe, send to jsp2 -->
                    <jsp:forward page="jsp2.jsp"/>
                </c:otherwise>
            </c:choose>
        </c:otherwise>
    </c:choose>
   
  </body>
 
</html>


JSP2:
<%@ page contentType="text/html;charset=windows-1252" isELIgnored="true" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>jsp2</title>
  </head>
  <body>

    <sql:transaction> 
        <sql:update>
            INSERT INTO COURSES(COURSE, DESCRIPTION, CREDITS)
            VALUES(?,?,?)
            <sql:param value="${cID}"/>
            <sql:param value="${desc}"/>
            <sql:param value="${credits}"/>
        </sql:update>
    </sql:transaction>
   
    <p>Data successfully added to Courses table.</p>   
    <p>Successful inserts: <c:out value="${ins}"/> Unsuccessful inserts: <c:out value="${not}"/></p>

  </body>

</html

Name: Anonymous 2011-05-12 23:38

Idk WHAT happened, I changed literally NOTHING, but now it's working.

Facepalm.

Don't change these.
Name: Email:
Entire Thread Thread List