0
package jee5study.exercise.disboard.servlet;

import java.io.*;
import java.net.*;
import java.util.*;

import javax.servlet.*;

public class Board implements servlet {
    
    private String SvName;
    private Date Started;
    
    public void init(ServletConfig config) {
   
        SvName = config.getServletName();
        Started = new Date( (java.lang.System.currentTimeMillis()));
        System.out.println("Servlet: " + SvName);
        System.out.println("  Started: " + Started.toString());
  }
    public void destroy() {

        Date stopped = new Date( (java.lang.System.currentTimeMillis()));
        System.out.println("Servlet: " + SvName);
        System.out.println("  Destroyed: " + stopped.toString());
}
   protected void processRequest(ServletRequest request, ServletResponse response) throws SevletException,IOException {       
  
        String user = request.getParameter("user");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        
        out.println("<html>");
        out.println("<body>");
	  out.println("<head>");
        out.println("<title>Board Title</title>");
	  out.println("</head>");
        out.println("<h2>Board Title</h2><HR>");
        
        if (user != null) {
           out.println("<p>Hello " + user +"!");
        }
        out.println("<p>My name is " + SvName);
        out.println("<p>I was started on " + Started.toString());

        out.println("</body>");
        out.println("</html>");
        out.close();
 
    
    /** Returns a short description of the servlet.
     * @return
     */
    public String getServletInfo() {
        return "Board Template";
    }
    
        public ServletConfig getServletConfig() {
        return getSevletConfig();
 
}
public void service(ServletRequest servletResponse, ServletResponse servletResponse) throws ServletException,IOException { processRequest(servletRequest,servletResponse);
}

Hey Guys, When i compile the above in J2EE building a servlet, i get an error saying that "Reached end of file while parsing" Please assist me on how to solve it.

Thanks

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jenn11
0

You forgotten to put closing bracket in your "processRequest" method, and same goes for closing whole class after method "service".

PS: implements servlet, servlet should be capital "S"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.