使用,与其他“服务器”应用程序相比,servlet的重要性

问题描述:

Where are servlets used today ?

I know that servlets are modules that run inside request/response-oriented servers, such as Java-enabled web servers. But now i don't hear anyone working with servlets.It may be that 'I' don't have people around who are much interested in servlets. But the thing is where servlets are used can't we write scripts in PHP or program in asp for that part ?

When i came to know that JDK'S IO classes can only work with system files,i thought of writting the particular application in php but because i love java i gave a look at servlet.

My knowledge of servlets is not much,but because i needed some application on server that could generate a response when a button is clicked from my applet i came across servlet. But then i thought is there anything that only servlets can do ?

So,is it worth learning to write servlet (or should i do in php/asp) when my goal is to write on a remote server file ?

UPDATE

This question is open to more 'fine` answers.None of the answer has actually answered the question

今天使用的servlet在哪里? p>

我知道servlet是在面向请求/响应的服务器内运行的模块,例如支持Java的Web服务器。 但现在我没有听到任何人使用servlet。可能是“我”周围没有人对servlet很感兴趣。 但是,使用servlet的地方不能在 PHP code>中编写脚本,或者在 asp code>中为该部分编写脚本吗? p>

我开始知道JDK'S IO strong>类只能用于系统文件,我想在php中编写特定的应用程序,但因为我喜欢java,我看了 servlet code>。 p>

我对servlet的了解并不多,但是因为我在服务器上需要一些应用程序,当我从我的applet点击一个按钮时会产生响应我遇到了 servlet 代码>。 但后来我觉得有什么只有servlet可以做的吗? em> p>

那么,是否值得学习编写servlet (或者我应该在php / asp中做) em>当我的目标是写在远程服务器文件上时? p>

更新 strong> p>

这 问题是对更多“罚款”答案持开放态度。答案中没有一个实际回答了问题 em> p> div>

In the web (client-server) environment, a typical requirement is that browser submits some data to the server and server executes some code to fulfill the request. Most of the web technologies provide some way or the other to achieve this. Servlets is the Java way to do this. I believe there isn't anything which a Servlet can do and a PHP/ASP cannot do. Its the matter of choice of platform. If your platform is Java you use Servlet (explicitly or implicitly) or else you use ASP (MS platform), PHP (LAMP).

And this is not the end, whether you use Servlet/PHP/ASP depends on lot many other factors such as

  • Existing development platform if you want to leverage it
  • Development time (some type of sites can be developed much quicker in PHP than in java )
  • Your budget off course
  • Existing know how (you don't wanna learn ASP if you already know PHP)
  • Open Source / Developer Community support

To answer your specific question, I am not aware if any use case wherein only Servlets can do but at the same time I am limited by my experience. I would be curious to know of such a use case exist.

Whether you should learn Java is really dependent upon precisely what you want to do. I use Java when I am writing larger more complex systems. I prefer the more rigid structure of Java. I use PHP for quick scripts in Drupal.

You may prefer to do everything in PHP, there is no real reason not to if that is your preference.

A similar question was asked a year ago. A lot of the answers apply. https://softwareengineering.stackexchange.com/questions/17053/what-is-java-used-for-these-days

Servlets are used as internal components inside higher level frameworks. I use Wicket currently, and I've used Spring MVC. There's a long list in Wikipedia. You don't hear of many people working with Servlets because Servlets are a low level API, and it's generally more productive to use a higher level API and concentrate on the application.