Loading
Invoke a Servlet from main()

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  Can I create a Servlet Instance and invoke that from a Main method ?


Ans)

In reality this would not make sense to create a Servlet from a main(string str[]) {},
but  you could , in that case the Servlet just behaves like a Plain Java class, no life-cycle methods
would be invoked , container will not manage the Servlet Life-Cycle.

If you want invoke a Servlet from a standlone class please use HttpURLConnection or some
Httpclient like Apache etc.,

 URL url = new URL(strUrl);
 HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
 urlConn.connect();



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Invoke a Servlet from main()


Invoke a Servlet from main()

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free