Welcome to Abdul Malik Ikhsan's Blog

Servlet, i’m coming

Posted in Tutorial Servlet by samsonasik on June 9, 2007

kebanyakan dari kita maunya enaknya saja, langsung ke jsp, padahal tidak tahu bahwa embahnya jsp itu servlet, ya java, cure java, murni java,nanti kelasnya dipanggil di browser, ok…, kita mulai program servlet kita. :
/*
*simpan file ini dengan nama HelloWorld.java
*simpan pada WEB-INF\classes
**/
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet{
 public void doGet(HttpServletRequest request,HttpServletResponse response)
  throws ServletException, IOException{
   PrintWriter out=response.getWriter();
    out.println(“Halo dunia….”);
  }
}
/*
*compile file tersebut.
**/
setelah dicompile, kita lakukan, kita ubah configurasi xml-nya, buka WEB-INF\web.xml, lalu tambahkan
…..
<servlet>
  <servlet-name>HelloWorld</servlet-name>
  <servlet-class>HelloWorld</servlet-class>
 </servlet>
…..
Panggil di browser, contoh http://localhost:1234/servlet/HelloWorld/HelloWorld 
kalau di tomcat tidak berhasil, coba pakai orion webserver.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: