File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Declaration of static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Declaration of static" Watch "Declaration of static" New topic

Declaration of static

leela mohan

Joined: Oct 31, 2006
Posts: 13
Suppose i declare static method in servletclass in that method i want print "hi" it is possible or not ?
static method can also call by classname
so please tell me answer
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
yes , servletname.methodname()

Rahul Bhattacharjee
LinkedIn - Blog
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

nothing will stop you in declaring static methods in servlet class. But what is the need in writing static method in servlet? can you explain us little bit about your requirement?

Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />
Chaitanya Devavarapu

Joined: Dec 06, 2006
Posts: 19
You can do it absolutely.
But, why need to declare a static method in servlet.
If you can tell your exact requirement, I can choose an appropriate

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

You can hit yourself in the middle of the forehead with a ball-peen hammer too.

Static methods have their uses, but you have not explained why you would want to do this. Chances are there are better means.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Declaration of static
jQuery in Action, 3rd edition