[JAVA] JSP error display from Servlet

import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Random;

import java.util.Date; import java.util.Random; import javax.servlet.RequestDispatcher; import org.camp.servlet.ResultData;

/** *

String luckList [] = {"Daikichi", "Nakakichi", "Kichi", "Hankichi", "Suekokichi", "Bad", "Small bad", "Half bad", "Bad", "Bad" , "Danger"}; Random rand = new Random(); //乱数所得 Integer index = rand.nextInt(luckList.length); out.print ("Your fortune today" + luckList [index]); /* TODO output your page here. You may use following sample code. / out.println(""); out.println(""); out.println(""); out.println("Servlet FortuneTelling");
out.println(""); out.println(""); out.println("

Servlet FortuneTelling at " + request.getContextPath() + "

"); out.println(""); out.println(""); ResultData data = new ResultData(); data.setD(new Date()); data.setLuck(luckList[index]); request.setAttribute("DATA",data); The (result) part of the line below will be displayed if the symbol cannot be found due to an error. Please point out that it is useless even if you try various things. RequestDispatcher rd =request.getRequestDispatcher(result); rd.forward(request,response);
} } // /
* * Handles the HTTP GET method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
}

/**
 * Returns a short description of the servlet.
 *
 * @return a String containing servlet description
 */
@Override
public String getServletInfo() {
    return "Short description";

}// </editor-fold>

}

Recommended Posts

JSP error display from Servlet
Passing parameters from JSP with Servlet
Xcode12 tableView display error
Suffering from MyBatis foreach error
From Ruby on Rails error message display to Japanese localization
Java Servlet / JSP View drawing
Getting Started with JSP & Servlet
How to use scope (JSP & Servlet)
[Android] Display Snackbar from any position
[Rails] Display form error messages asynchronously
Java Servlet / JSP Request Scope Part 2
Switch from JSP + JSTL to Thymeleaf
Animated display of Swift error messages
Hello World with GlassFish 5.1 + Servlet + JSP
About image upload of jsp (servlet)