Thursday, December 4, 2008

Example Building : HelloWorld Servlet Code Example on Weblogic

HelloWorld Servlet Example on Weblogic

1. Directory Structure for your Helloworld servlet :



2. Code:

Note :- Place the source file in WEB-INF/src/test/ directory.

package test;

import java.io.*;

import javax.servlet.http.*;
import javax.servlet.*;

public class HelloServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
out.println("Hello, world!");
out.close();
}
}

3. Configuration Files

Note :- Put the configuration files in WEB-INF directory.

Web.xml :-

















Weblogic.xml :- This file is optional for this example.But this is for reference.






4. Compile the servlet code and place in WEB-INF/classes/test/ directory
Make jar (name of jar file : test.jar ) file and upload it on weblogic.

5. URL for accessing the servlet is :
http://localhost:7001/test/hello/


Note :- For any questions you can leave your comments.

No comments:

Post a Comment