Click here to Skip to main content
14,301,484 members
Rate this:
Please Sign up or sign in to vote.
See more:
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("&lt;html>");
out.println("&lt;head>");
out.println("&lt;title>Servlet WordServlet&lt;/title>");
out.println("&lt;/head>");
out.println("&lt;body>");
out.println("<h1>Servlet WordServlet at " + request.getContextPath () + "</h1>");
out.println("&lt;/body>");
out.println("&lt;/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>
&lt;html>
&lt;head>
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
&lt;title>JSP Page&lt;/title>
&lt;/head>
&lt;body>
<h1>Lab 3!</h1>
&lt;form method="POST" action="ViewServlet">
&lt;input type="text" name="txtinput">&lt;/input>
&lt;input type="submit" name="Button" value="Add">&lt;/input>
&lt;input type="submit" name="Button" value="List">&lt;/input>
&lt;/form>
&lt;/body>
&lt;/html>
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You didn't mention the complete error message(full stacktrace), check this
Class javax.ejb.EJBException[^]
Class EJBException[^]
BTW you can solve your issue by posting the complete error message in Google.
   
Comments
Avani Mathur 1-Feb-12 14:57pm
   
This is exactly the error.......

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.ejb.EJBException

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
GlassFish Server Open Source Edition 3.1.1
Amir Mahfoozi 2-Feb-12 3:32am
   
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100