0

Hi Daniweb team,
I am developing the sample servlet program.This is my sample program.

Servlet Code:

package org;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet{
            public void doGet(HttpServletRequest req,HttpServletResponse rsp)throws ServletException,IOException{
                 PrintWriter out=rsp.getWriter();
                String type=req.getParameter("type");
                if(type==null){
                        out.print("success");
                }
                else{
                        out.println("Not a Null value");
                }
         }
       }

I want to pass the values through URL and check whether the given parameters are null.
I am using the apache tomcat server.

I have mentioned url below:
http://ipaddress/HelloWorld/src/HelloWorld.java?type=1

When i execute the above url the full code is displayed in the browser.Can any one know how to execute this above code.There is no error in the above code and i executed successfully the class file is also generated.

Thank you,

Regards,
Premnath.M

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by stephen84s
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.