Hi,
I have a small question regarding the exception i get for my servlet:
javax.ejb.EJBException
The output screen shows that the error is in my servlet in the processRequest method which is:
public class ViewServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String s=request.getParameter("Button");
String w=request.getParameter("input");
HttpSession session=request.getSession(false);
ListRemote r=(ListRemote) session.getAttribute("R");
if (r==null)
{
session=request.getSession();
try{
Context ctx=new InitialContext();
r=(ListRemote) ctx.lookup(ListRemote.class.getName());
session.setAttribute("R", r);
}
catch(NamingException ne){}}
if (s.equalsIgnoreCase("Add"))
{
r.AddMethod(w);
response.sendRedirect("/index.jsp");
}
else
{
ArrayList<String> WordList=r.ShowMethod();
for (String i:WordList)
{
out.println(i);
}
}
try {
/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet WordServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet WordServlet at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
*/
}
finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</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 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>
}
Also, I am posting my jsp page if there is any code mistake in that too:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Lab 3!</h1>
<form method="POST" action="ViewServlet">
<input type="text" name="txtinput"></input>
<input type="submit" name="Button" value="Add"></input>
<input type="submit" name="Button" value="List"></input>
</form>
</body>
</html>