How to use pure Java in web applications without JavaScript knowledge? [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I love Java like hell. This is not my 'native' language in work and I do Java projects from time to time after work. I have used only few technologies with Java like communication via raw sockets and Swing. Once in the past I run the Apache-Tomcat with very simple JSP generated page. Really basic stuff.
Some time ago I was interviewed to participate in more commercial Java project. It was a web-service based on browser content/application... I heard words like 'JSON', 'GWT', 'AJAX', 'XML' and I was lost in answers. ... I suggested java Applets+Swing, but they wasn't interested. I realized I have extremely limited knowledge about web technologies. I looked very bad on this interview.
If I am not a JavaScript guy, can I really do web-apps with pure Java? I mean web pages with dynamic-fancy-elements which are I think provided mostly by the JavaScript. What technologies should I get to know? Can be JavaScript generated from Java code?

I'll make this a CW answer, because the question isn't a fit for Stack Overflow's "one right answer" format.
Yes, you can write browser applications without knowing JavaScript. One way to do that is to use the Google Web Toolkit. (Amusingly, this was one of the acronyms you heard but didn't know — GWT.)

Why we need Javascript?
to reduce load on the server, by doing things like input validations before submitting the data to server.
Can all this be done without Javascript?
Yes, you can have plain HTML and do all the validation from your Java code
Is it good idea?
No its not. By doing so, you are loading the server for simple tasks such as input validations which can be easily accomplished by Javascripts.
I don't know Javascript. With ONLY Java can I get rich web-app?
Yes, GWT is google's tool which allows you to achieve the same. GWT gives you Eclipse plugins to manager the GWT web-apps and it allows you to write plain Java code (absolutely no Javascript) and in the backgroud coverts them into Javascript, so that the rich UI is created with most of the UI event handling in the browser itself.

From someone who has Java as their go too language, develops web applications and doesn't particularly like JavaScript I'd say... just learn JavaScript. Sure it's not a very nice language (IMHO) but it's absolutely essentially now-a-days. JavaScript appears just about everywhere now from JavaFX to web services (e.g. JSON) to web applications. Java has a JavaScript engine in Rhino and is getting a new one in Java 8 called Nashorn so I'd expect to see more JavaScript not less.
In direct answer to your question, yes, you could write a web application without knowing any JavaScript but before long you'll find a situation where you have to hack on some JS or debug it and then you'll kick yourself for not having learnt it from the start.

To give a short answer, Yes you can but then the Javascript will be generated for you. There are many frameworks that will generate the Javascript for you. Maybe you should look at Vaadin if you don't like writting javascript at all.
On most projects there is no need for writting javascript on scratch. 99% of time we use jQuery or plugins based on those. Maybe you should have a look at the Twitter bootstrap.

Related

Are Java and JSP really so different? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am planing to rewrite my desktop finance application (written in Delphi) as web application and am thinking which technology to use. Other possible requirement is to transfer as much code as possible to shared library which could be used in desktop version of the application too. There is no such parameter as total cost of owhership. I can rewrite it as long as I want.
I need a cross-platform technology which is able to handle UTF-8 natively and connect to PostgreSQL as well as Microsoft SQL Server.
I have programmed enough with Ruby on Rails and will say that it is quite good for commercial websites but does not fit for my own web application, as I do not like its "magic" and inability to write .rb files in UTF-8.
PHP seems to be similar to RoR although I haven't tried it.
ASP.NET / .NET MVC meets my requirements except it is for Windows only.
So, I've chosen Java. But they say in Internet that Java and JSP are different technologies and I can not take Java desktop application and with very little changes convert it to JSP. Are Java and JSP really so different? For example, in .NET I could write a database- and business-logic-library which could be used in desktop application as well as in ASP.NET application.
Java and JSPs are not different. JSP gets compiled into Java Servlet before execution.
JSP is meant for writing HTML/ASP like code dealing with presentation. In other words, it gives segregates presentation detail from Java coding, but in the end, server compiles your JSP files into Java Servlets.
What you want to write in JSP, can be written through Servlet.
If you plan to use JSP over Servlet, please make sure you are not writing entire code in JSP itself e.g. reading data from database. All the business logic should go in JAVA classes and used in JSP through your JAVA classes. Your Java classes can be reused if designed appropriately.
If I understand you right, this is what you are trying to achieve i.e. achieve re-usability of your application logic.
They are not that different besides you can reuse your services, logic etc. in the same way .NET does it.
The only problem is the view, there are many ways of doing it in java. If you've chosen JSP you will need to code all your presentation (you can invoke your services, logic, etc.), but if you want reuse as much code as possible in a Desktop java application an take it to the web perhaps your should take a look at java Applets which are relatively simple to turn into a java application.
For the situation that you describe it should be pretty easy to have a lot of shared code for both the desktop and the web application.Think of the application as consisting of 2 layers:
Layer 1: Business logic and Database access code, this layer just pure java it should not depend on any technology that can not run outside the container. For example, you can use JPA for database access, and Spring to organize your business logic into nice modular units. If you write a comprehensive test suite for this layer, then you would have confidence that your business logic works correctly and it would it make it easier to figure out if a bug is a web app bug or a desktop bug.
Layer 2: UI logic, you will need two instances of this layer, one written using a desktop UI technology like Swing,or JavaFX and another layer UI layer written in a Web application programming technology such as JSP / Servlets, JSF, SpringMVC, .... etc. This UI layer will depend on the Layer 1 and because of the comprehensive test suite for layer 1 you can be confident that the operations it calls upon on layer 1 are good.
As far as web development technology I would recommend that you consider higher level frameworks that JSP and Servlets, because that will save you a lot of time.
There is a possibility to be able to write a single UI layer using JavaScript, HTML 5 which is a web app but behaves like a desktop app for many features. You can then make a desktop version of your product that basically launches a browser windows without the chrome and runs the app within it. If you do choose to go down this road of using JavaScript and HTML 5 there are plenty of frameworks to choose from, I would recommend that you watch the videos on infoq.com from the ThroneOfJS conference http://www.infoq.com/throne_of_js/ to get an idea of what frameworks are available my biased recommendation would be for using AngularJS.

Java PlayFramework & Python Django GAE [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I already know Java, C# and C++. Now I want to start with web development and I saw that some really big sites are built with Python/C++. I like the coding style of Python, it looks really clean, but some other things like no errors before runtime is really strange.
However, I don't know what I should learn now. I started with Python but then I saw that Google App Engine also supports Java and the PlayFramework looks amazing too.
Now I am really confused. Should I go with Python or Java? I found the IDE for Python "PyCharm" really amazing for web development. Does Java have something similar, eclipse maybe?
I know that this question isn't constructive, but it will help me with my decision. What are pro and cons of both languages?
I just want to add, that if it is a requirement for you that it is compatible with GAE, then I think Django is the best choise. Playframework is of version 2.0 no longer compatible with GAE.
PyCharm is an IDE created by JetBrains. Originally, JetBrains only had one product, IntelliJ IDE (a Java IDE), and PyCharm and all the other products were spawned from that one highly successful product.
As for which language, I would suggest trying to do something small (but feature rich enough to be a holistic test) with all 3 and see which one works best for you. Language choice is a massive question, and depends on personal factors, project factors and many other besides. Therefore I won't even begin to tell you which one is best (because it would be what is best for me, in my situation).
It depends on you. What do you want more: learn new programming language or learn how to make web apps?
I just started few PLay tutorials and it's really great. PLay 2 is even more amazing than previous one. I'd like to learn Scala, so it's perfect for me, but also because of that it's not GAE compatible anymore, but come on, there are other ways to deploy apps, I'd like to try OpenShift (dunno if it's possible, I'll try it soon).
I'm also a big fan of Python, so it's naturally that I'm also looking for frameworks to build apps in that. I would say, that Django isn't the only choice. I had few tries with Django, right now I'm trying web2py. As many stated, Django has quite hard learning curve. Web2py should be better, but I don't like the 'wizzard' way of scaffolding apps.
I've used Bottle (Flask is similar) and it's great for small apps. RESTful apps are super-easy with them, so maybe it should be your starting point.
From what I've read about Python's frameworks:
Django is quite good for typical websites/CMS-like, hard to learn
web2py very interesting --- I'm in the middle of testing that, Reddit's using it?
web.py -- minimalistic, lightweight framework, you have to build webapp almost from scratch
Tornado/Twisted --- fast, async frameworks
Flask/Bottle --- very nice microframeworks. Great for REST services
I've not tried them all, but it's what I've found out during reading the web/blogs etc.
I'm looking for something like Play Framework 2.x but in Python(ideally 3) :)

What development stack should I learn to move from ASP.NET development to Java? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
So here's the story: I currently work as a C# developer doing ASP.NET. While I like C# I don't like the overall quality of the .NET community; most of my past experiences have been that many .NET developers are totally ignorant of actual software engineering (e.g. design patterns, code separation, etc.). The Java area seems a lot better in this regard even if you do have to put up with the occasional "architecture astronaut".
My actual question is this: I can pick up the Java syntax easy enough since I already know C#. However, I've only worked with the full Microsoft stack for web development (WebForms, although I've looked a bit at MVC and I've done some Ruby on Rails demo stuff so I know MVC fairly well). If I want to learn enough marketable skills to be able to apply for junior-level Java development positions at companies, what stack should I look at? There are dozens of Java web frameworks out there; what would be the most common one used in companies? It seems that Hibernate is the default standard for persistence (I've done a little bit with NHibernate) so I'm okay with that. I've also seen several new Java web frameworks that seem interesting, but learning them won't give me a leg up in applying for a job at a company because I'm bettering they're untested in the corporate world and aimed at startups and similar like most new frameworks.
Which framework would be the most likely to be used at a typical company that I should start to learn in order to begin a transition to a better quality community?
I'd actually recommend that you start by learning straight JDBC for database access and servlets+JSP for the web front end, and using those to implement a (very) simple web app. JDBC is the API on which basically all other Java database libraries are built, and likewise for servlets. These will require the least configuration necessary to get your app running. Once you've done that, you'll have a better foundational understanding and can take a look at:
Hibernate with JPA for persistence
Spring for dependency injection
One of the many web frameworks - Spring MVC, Struts 2, JSF or Seam are all viable
Java EE components such as EJBs.
If you're looking to do this on a full-blown Java EE container, I'd recommend using Glassfish as your server. But Tomcat is simpler (just a servlet container), and might be better for starting out with the first project.
Get familiar with Apache and JSP stuffs would also be helpful in addition to the answer above.

Are there any new/updated Java web development frameworks to watch for? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I know recently Spring 3.0 was released which brought about a nice new set of features and ease of web development with their MVC package. However are there any new frameworks on the horizon and/or new versions of other frameworks that a web developer should have their eyes on?
I heard about the Stripes framework, but it seems as though development has stopped. It also seems grails has a new release coming out as well which that looks like it is just an update to support the new features in the latest groovy release.
Apache Wicket - light-weight component-based web application framework with strong separation of presentation and business logic.
Look also at the Spring Roo and Play framework and I almost forgot about the Vaadin. There are often enough new/upgraded java web frameworks:)
Have a look at JSF with JSR-299 in the Java EE 6 standard. You can do quite a bit, and it is standardized.
Version 2.0 of the Google Web Toolkit was released back in December. Some of the new stuff:
Development Mode: Previously you needed to use a "hosted mode" pseudo browser to quickly test your code (i.e. avoid a compile/deploy step). In 2.0, development mode allows on-the-fly running and debugging in any browser. This give big wins in speed and tooling (you can use Firebug etc.)
Speed Tracer: A plugin for Chrome that gives you highly detailed performance profiling for your GWT (or any) client AJAX code.
Compiler Optimizations: One of the great things about GWT is that the compiler is improved almost with every release meaning that you get a performance boost just by recompiling your code.
Code Splitting: You put 'splits' in your code, allowing the browser to download just the code it needs to get started and download the rest when it's needed (great for apps with very large amounts of client code).
Declarative User Interfaces: Define UIs in XML. Much less boilerplate code. XML<->Java integration via annotations.
Layout Panels: Improved, standards-compliant, base panels.
Bundled Resources: Image bundling from previous resources has been generified to allow any type of resource to be "bundled", reducing the number of requests the browser makes and allowing your app to load more quickly.
GWT works especially well with a good IDE (Eclipse or IntelliJ) since the IDE can take advantage of compile-time information from GWT, validating, on the fly your client code (since it's Java) and also things like CSS class name references and references between XML UI definitions and backing code.
I thought it was worth noting this as I just heard about the new release on java lobby. The
lift framework. It is written in scala, which is java per say.
Appfuse - Not really a framework, but it might be worth a look if you're looking for something to ease the initial ramp up effort on a Java EE project. It provides a bunch of Maven 2 archetypes that will create a "ready to run" application based on any of:
Struts 2
JSF
Tapestry 5
Spring MVC
Struts 2 is also very much worth a look. Totally different animal to Struts.

How do you make websites with Java? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
This might be a really trivial question, but I've been writing Java programs at my school and I just found out that I can create websites with Java as well.
How can I do that? Any good books/tutorials for that?
Which is better for Web development, Java or PHP?
Also, when using PHP, MySQL comes into picture and while writing Java programs for desktop, we just use File I/O, so what is better for web dev, File I/O or MySQL?
You are asking a few different questions...
How can I create websites with Java?
The simplest way to start making websites with Java is to use JSP. JSP stands for Java Server Pages, and it allows you to embed HTML in Java code files for dynamic page creation. In order to compile and serve JSPs, you will need a Servlet Container, which is basically a web server that runs Java classes. The most popular basic Servlet Container is called Tomcat, and it's provided free by The Apache Software Foundation. Follow the tutorial that cletus provided here.
Once you have Tomcat up and running, and have a basic understanding of how to deploy JSPs, you'll probably want to start creating your own JSPs. I always like IBM developerWorks tutorials. They have a JSP tutorial here that looks alright (though a bit dated).
You'll find out that there is a lot more to Java web development than JSPs, but these tutorials will get you headed in the right direction.
PHP vs. Java
This is a pretty subjective question. PHP and Java are just tools, and in the hands of a bad programmer, any tool is useless. PHP and Java both have their strengths and weaknesses, and the discussion of them is probably outside of the scope of this post. I'd say that if you already know Java, stick with Java.
File I/O vs. MySQL
MySQL is better suited for web applications, as it is designed to handle many concurrent users. You should know though that Java can use MySQL just as easily as PHP can, through JDBC, Java's database connectivity framework.
Read the tutorial on Java Web applications.
Basically Web applications are a part of the Java EE standard. A lot of people only use the Web (servlets) part with additional frameworks thrown in, most notably Spring but also Struts, Seam and others.
All you need is an IDE like IntelliJ, Eclipse or Netbeans, the JDK, the Java EE download and a servlet container like Tomcat (or a full-blown application server like Glassfish or JBoss).
Here is a Tomcat tutorial.
I'll jump in with the notorious "Do you really want to do that" answer.
It seems like your focus is on playing with Java and seeing what it can do. However, if you want to actually develop a web app, you should be aware that, although Java is used in web applications (and in serious ones), there are other technology options which might be more adequate.
Personally, I like (and use) Java for powerful, portable backend services on a server. I've never tried building websites with it, because it never seemed the most obvious ting to do. After growing tired of PHP (which I have been using for years), I lately fell in love with Django, a Python-based web framework.
The Ruby on Rails people have a number of very funny videos on youtube comparing different web technologies to RoR. Of course, these are obviously exaggerated and maybe slightly biased, but I'd say there's more than one grain of truth in each of them. The one about Java is here. ;-)
While a lot of others should be mentioned, Apache Wicket should be preferred.
Wicket doesn't just reduce lots of boilerplate code, it actually removes it entirely and you can work with excellent separation of business code and markup without mixing the two and a wide variety of other things you can read about from the website.
Also be advised, that while Java is in general very beginner friendly, getting into JavaEE, Servlets, Facelets, Eclipse integration, JSP and getting everything in Tomcat up and running is not. Certainly not the easiest way to build a website and probably way overkill for most things.
On top of that you may need to host your website yourself, because most webspace providers don't provide Servlet Containers. If you just want to check it out for fun, I would try Ruby or Python, which are much more cooler things to fiddle around with. But anyway, to provide at least something relevant to the question, here's a nice Servlet tutorial: link
Look into creating Applets if you want to make a website with Java. You most likely wont need to use anything but regular Java, unless you want something more specialized.
I'd suggest OOWeb to act as an HTTP server and a templating engine like Velocity to generate HTML. I also second Esko's suggestion of Wicket. Both solutions are considerably simpler than the average setup.

Categories