0 Replies Latest reply: Mar 11, 2012 12:18 PM by 777287 RSS

    JSP application Error 404: The server has not found anything matching the R

      Running Win Server 2008 64 bit. Using JDev Studio Edition Version

      I'm writing a test application which gives the user an interface to write custom queries. The application cosists of two Java classes, a jsp page and web.xml. I run the application on the integrated WLS in J dev. The jsp page displays fine, but when I press the <EXECUTE> button I get ' Error 404--Not Found - The server has not found anything matching the Request-URI' . Any advice would be greatly appreciated. Following is the contents of the application:

      <?xml version = '1.0' encoding = 'windows-1252'?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">



      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      <%@ page contentType="text/html;charset=windows-1252"%>
      <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
      <c:if test="${sqlStatement == null}">
      <c:set var="sqlStatement" value="select * from User" />

      manaar SQL Gateway
      Enter a SQL statement and press the execute button

      SQL Statement:
      <form action="sqlGateway" method="post">
      <textarea name="sqlStatement" cols="60" rows="8">${sqlStatement}

      <input type="submit" value="Execute">

      SQL Result:





      package mmv2;

      import java.io.*;

      import javax.servlet.*;
      import javax.servlet.http.*;

      import java.sql.*;

      public class SqlGatewayServlet extends HttpServlet {
      protected void doPost(HttpServletRequest request,
      HttpServletResponse response) throws ServletException,
      IOException {
      String sqlStatement = request.getParameter("sqlStatement");
      String sqlResult = "";

      try {
      // get a connection
      String dbURL = "jdbc:mysql://<server>/*******";
      String username = "root";
      String password = "**********";
      Connection connection =
      DriverManager.getConnection(dbURL, username, password);

      // create a statement
      Statement statement = connection.createStatement();

      // parse the SQL string
      sqlStatement = sqlStatement.trim();
      if (sqlStatement.length() >= 6) {
      String sqlType = sqlStatement.substring(0, 6);
      if (sqlType.equalsIgnoreCase("select")) {
      // create the HTML for the result set
      ResultSet resultSet = statement.executeQuery(sqlStatement);
      sqlResult = SQLUtil.getHtmlTable(resultSet);
      } else {
      int i = statement.executeUpdate(sqlStatement);
      if (i == 0) // a DDL statement
      sqlResult = "The statement executed successfully.";
      else // an INSERT, UPDATE, or DELETE statement
      sqlResult =
      "The statement executed successfully.
      " +
      i + " row(s) affected.";
      } catch (SQLException e) {
      sqlResult =
      "Error executing the SQL statement:
      " + e.getMessage();

      HttpSession session = request.getSession();
      session.setAttribute("sqlResult", sqlResult);
      session.setAttribute("sqlStatement", sqlStatement);

      String url = "/sql_gateway.jsp";
      RequestDispatcher dispatcher =
      dispatcher.forward(request, response);