I'm currently working on a web-application project right now and I shifted from PHP to Java. Im new to JSP, JSTL and JavaBeans but I dont have problems compiling and working with them and actually enjoying. what I want to ask if I still need to learn Servlet? Im beginning to get annoyed with servlet programming, cant compile even just a simple Hello World application. Im using Netbeans 6.8 with glassfish v3. I dont have problems with JSP, JSTL and JavaBeans even if I connect it with MySQL. any advise or suggestions guys?

Dani AI

Generated

Switching from PHP to JSP/JSTL/JavaBeans is a solid move for server-side Java; those technologies are primarily the view layer, while servlets provide the HTTP lifecycle and the controller glue that connects views to business logic. was on the right track: understanding a minimal servlet clarifies request/response flow, session handling, filters, and why many frameworks sit on top of the servlet API.

Quick, practical checklist to get a Hello World servlet working in NetBeans 6.8 + GlassFish v3:

  1. Create a Web Application project (Java EE 6) and select GlassFish v3 as the server.
  2. Use File > New File > Web > Servlet (the IDE wizard sets imports, package and mapping).
  3. Example minimal servlet:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;

@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello World");
  }
}
  1. Run the project from NetBeans and open .
  2. Common build/deploy traps to check: inspect the IDE Output and GlassFish domain log (domains/domain1/logs/server.log), confirm the project uses a JDK (not only a JRE), remove any servlet-api.jar from WEB-INF/lib (server provides it), and make sure package declarations match the folder layout.

If servlet boilerplate feels tedious, higher-level frameworks (Spring MVC, JSF, Struts) reduce manual servlet code but still rely on the servlet API; learning servlet basics first makes those frameworks far easier to adopt. Given ’s comfort with JSP/JSTL, pairing a small servlet controller with JSTL-backed views is a lightweight, maintainable next step.

Recommended Answers

All 2 Replies

yes, you will need servlets for your business logic, the backend.
Suggestion: get a good (and recent, the specs changed a bit over the years) book and start learning.

is there any other way than using servlet? lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.