1

Hypothetically, could java be used to write a website instead of, say, asp.net. or php?

quakkels
  • 11,676
  • 24
  • 92
  • 149
  • 1
    JSP, Servlet. Google those terms. – jjnguy Nov 08 '10 at 22:09
  • Those links may be helpful: [What's the Java alternative to ASP.NET/PHP?](http://stackoverflow.com/questions/2556553), [Analogues of Java and .NET technologies.](http://stackoverflow.com/questions/2526024) [Java webdev, what skills do I need?](http://stackoverflow.com/questions/1958808), [JSP tag info page](http://stackoverflow.com/tags/jsp/info) and [Servlets tag info page](http://stackoverflow.com/tags/jsp/info). As to erickson's comment, it was just sarcasm :) Guess what Google uses under the covers. – BalusC Nov 08 '10 at 22:31
  • @everyone - Ok... this is what i know about Java... It's used to write android apps, and the syntax is similar to C# (or vice versa) I am considering learning it and I was simply wondering what the other benefits of learning java could be... I already new about java applets... . I just wanted to know if Java had a web framework similar to .NET – quakkels Nov 08 '10 at 22:32

6 Answers6

6

J2EE is an entire branch of Java made towards running Java as a web server. It includes making it easy to code for distributed servers, a messaging protocol and database interaction. It's extremely powerful, well written and stable and you'll find it's used by many large web sites.

It's also very different from just coding a simple single-purpose server. Some of the complication is up-front/built in, so there is a larger initial learning curve but you won't encounter many of the problems you would if you tried to do it on your own...

For instance, imagine the most complex server-side code you've written--what would it take to make it run distributed across 2 servers (So that either server may answer any request with the requests based on server load)? If it were written in proper J2EE it would just be editing a few config files.

Bill K
  • 62,186
  • 18
  • 105
  • 157
5

Some would argue that this is what Java is mostly used for! Sarcasm aside check out the Wikipedia entry for Java Enterprise Edition for the summary and of course the official Oracle Java EE website for details.

Basically there is a whole host of mature server APIs and application servers from different vendors (including Open Source vendors) that implement those APIs. Server side Java is really a mini-industry with god knows how many companies, open source projects, conferences and the like.

If you are new to server side Java you coming in at a good time, you missed the dark days EJB 1.0 and 1.1 and now there is a rather useful, if a little heavyweight set of APIs on which to build your server side applications.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Tendayi Mawushe
  • 25,562
  • 6
  • 51
  • 57
3

Yes, it is actually quite common.

Alan Geleynse
  • 24,821
  • 5
  • 46
  • 55
0

I think so. It's the basis for JSP and Java Servlets.

Adam Holmes
  • 1,783
  • 3
  • 20
  • 32
0

Yes.You can use Tomcat web container or glass fish, JBoss,... There is few frameworks, like Tapestry, JSF,...

dormitkon
  • 2,526
  • 4
  • 39
  • 60
0

If you encountered a .jsp extension for a page, it was definitely Java (.jsp = Java Server Pages). Of course you can generate plain HTML (or whatever you want) as well.

Landei
  • 54,104
  • 13
  • 100
  • 195
  • Doesn't JSP generate "plain HTML" (and Javascript and CSS)? – Christian Mann Nov 08 '10 at 22:13
  • 1
    That is true with PHP or Perl or any scripting language. It is what you write that makes it different. If I have PHP do `echo 'hello';` it is plain text. If I have it do `echo '';` it is generating CSS. –  Nov 08 '10 at 22:16