Should I use PHP or JSP for a chat website? - java

I want to develop a website web chat application like yahoo. Only difference is that I want to make it web based not desktop.
I will be implementing it in jsp/php with ajax.
I want to know whether jsp or php will be better for this.
What will be advantages or disadvantages of both.
Which one of the two would you prefer and why?
Will jsp applicatioon will be slower then php?
I am thinking of using using struts with jsp and ajax . Will using of struts decrease speed?
I know jsp, java and struts but not php. Is php more difficult then jsp?

Use whichever one that you're a better programmer in.
The task can be accomplished in either language just the same. You can argue endlessly about language features, the bottom line will be whatever works best for you.

JSP based web applications are a bit more harder to deploy than PHP based web applications, but you gain the ability of creating Servlets.
PHP requires less server administration skills to setup properly and get running, is fast to learn, and allows fast creation of simple applications.
None is better than the other, they are different in nature. Check your requirements, and take a decision based on that. If your requirements doesn't favor one over the other, choose whichever your team is more comfortable with.

If you know both well then choose any.
But if facing difficulty then PHP is better to stay with.
Reasons:
fundamentally easy
large no. of developer libraries are available.
Easy to integrate with other scripting languages
But structural syntax becomes a problem as they are so many in cumbersome manner. Use PHP tag library for that works just like JSTL.
"Choosing language is not the problem but efficient implementation of code is the only hurdle."

JSP isn't a language - it's just a view/presentation technology - so it's only to build a web Frontend - while the main programming happens somewhere else - in the Java Language, as a so-called Java Servlet.
I personally like Java more, but PHP is okay, and if you only know PHP (which I must assume from the questions :) ) you're better off doing it in PHP now - you can learn Java later...
Apart from that, the others asking for more background info are right - you need to see what technology meets your requirements best...

Related

Can you write a web application with just the Java programming language?

My end-of-term assignment is to build a web-based student management application which connects to a MySQL database. However, the teacher does not allow us to use JS/ node because he says it is not OOP. Besides from JS, the members in our group can only use Java.
Therefore, I want to ask if it's it possible to do this assignment with just Java. If it is, what are the things I need to know and learn? Else, is it possible to learn PHP in 1 month for this kind of project?
Thank you very much for reading!
Yes it is possible to write a webserver in Java without any external (i.e. not Java SE) libraries. All you need to do is:
Learn about Socket and ServerSocket and the SSL stack, and ...
Spend a few days reading the HTTP specification in sufficient detail to understand what the protocol requires.
Spend a few more days implementing a server-side HTTP protocol stack and so on.
Which is ... a lot of effort, and probably a waste of you / your team's time.
If you are going to implement this in Java, you would be much better off either learning Spring / SpringMVC / SpringBoot, or learning Servlets and/or JSPs. They deal with the protocol side for you, and (more or less) leave you to focus on the aspects that are specific to your webapp.
These technologies (or equivalents) are what you are likely to use when you graduate.
If the other members of your team already know Java, that would be an obvious good reason to use it.
In short, there are 3 reasons to use Java + the above technologies:
Less effort
Less learning for your other team members1
You / they will be learning more immediately useful things.
PHP would be another alternative, though if your teachers are "down" on Javascript for being "not OO enough", they are probably unlikely to think well of PHP either.
On the topic of whether Javascript is OO or not, read this:
Is JavaScript object-oriented?
Read it and make up your own mind.
1 - How about volunteering to write all of the project's documentation so that you don't have to learn Java. No? You want to learn Java, don't you!
Sure you can write a web app in Java. Depending on what you're allowed to use there are tons of options. Just a short overview, further down means you need more 3rd party code but productivity goes up:
Build in on the JDK only. You'll need to build the WebServer on your own and compose HTML... (Only do this if requirements are strictly forbidding 3rd party libraries)
Use a servlet container like tomcat. You'll still have to build HTML on your own but request handling is mostly done for you. (Use this if a servlet container is all you're allowed to use)
Use a templating engine like JSP, Thymeleafe, Velocity. You will be able to build web pages quite easily. (This would already work conveniently, yet there are still better options)
Use an web application framework. This will take most boilerplate from you and allow you to use advanced concepts with little effort. There are multiple frameworks to choose from. I prefer Spring Boot and would recommend to start with s.th. like this (This will automatically provide much of what is asked from you, so check if you can use such a framework).

Integrating Javascript Frameworks with Java Web Frameworks

I have what I think might be a strange question to ask.
Recently I was playing with some java web frameworks (jsf with primefaces) and I noticed that it's quite good at handling form data or when you play along with the jsf components. I also did a project using grails and again it was useful for form data.
But the moment you want to do something which requires a little deviation; then I found myself doing weird things (examples are tag clouds with large strength values using primefaces and single page webapp forms with grails).
This resulted in some very messy html+javascript code for my grails things(which I blame on my inexperience with javascript). This was done because I was using expression language (grails in this case) to populate some of the javascript. The worst part was that I had a bunch of custom javascript code inline with my server pages (I could of refactored a little out but I think one would still have alot of javascript calls inside a single page).
So now to the question(s) :)
[main question] Are there any resources that demonstrates how to design or at least implement maintainable javascript with server pages (gsp, xhtml, etc) ?
The reason is that I find that there are some neat javascript frameworks, but using them with server pages seems a bit unnatural if one takes into account the expression languages for server side frameworks? Unless it's normal to do this type of thing :) ?
Are there appropriate frameworks for Single page webapps using java?
My current answer is that GWT, Vaadin (based off GWT) and perhaps JavaFX qualify. Maybe ZK, Flex and (Grails/Roo + Flex/GWT) also qualify as well?
Are java web frameworks still useful for presentation layers?
My current answer is that they might be when you are dealing with portal type webapps or Web 1.0 apps for lack of a better word. The other case is that they could be when you use alot of role based security and you want to filter things out based on roles, but even that has counter arguments.
My other answer to this is that it might be better to use a java server to provide your web services and then rely on something else to do the front end?
This might be OP, but for single page apps, it's easier to serve up data from the server via JSON(P)/XML/whatever and then use things like Backbone to process and modify the view(s) accordingly. That way, the server can use REST/SOAP/websockets/whatever, and the browser app becomes a full-fledged app.
I haven't actually done this, so don't quote me, but I imagine that it should make sense.

Python web frameworks vs Java web frameworks (how is web development in Python done?)

I am thinking in starting a personal pet web project to experiment with different things and extend my knowledge.
I use Java a lot at work (for web applications :D) and was thinking in making my own in Python since I kinda like this language but never passed the simple scripts stages.
I want to step up a gear regarding Python (using 2.6.5) and don't know what to expect or what framework to choose from: Django, Pylons, web2py etc.
I also don't know how much these frameworks will offer me and how much will I have to write from scratch.
I could use a comparison with Java if somebody can provide me with. I'm thinking at filter functionalities such as sitemesh, custom tags like JSTL; In Python, can I write clean pages of HTML with tags in them or write a lot of print statements (something like servlets did in Java etc?
I don't know exactly how to phrase this question.
I actually need a presentation of how web development is performed in Python, at what level, and what the web frameworks bring to the table.
Can you share from your experience?
TIA!
hi try bottle python framework (bottle.paws.de / bottlepy.org) its really nice to use blistering fast and gets out of your way + the best thing about it is that its one single file to import, i recently migrated from PHP and i have to tell you am so ... loving it!
Python web frameworks run the full gamut of capabilities/facilities, all the way from shims around WSGI such as Bottle and Flask, all the way to full frameworks such as Django and TurboGears, and even "megaframeworks" such as Zope. Each does things slightly differently, but there will be some familiarity from one to the next.
It may sound strange, but there's no need to know "how web development is performed in Python" to start doing it.
In fact, working with language/framework/etc is a single most reliable way to get understanding of it. You won't gain a lot from one-page summaries.
Also, comparing it with Java isn't likely to help. There's no point in doing "Java-style development in Python". If you want to benefit, you'll need to clear your mind and do everything "Python-way".
As to what Python framework to choose, Django seems like like a good starting point. It's very popular, which means you won't be left without tutorials/documentation/help.
PS Short version: just do it.
Python web frameworks do it in a similar way as some Java-based frameworks. I can speak for Django here.
A good comparison could be Play! vs. Django. Both of them foster using an MVC architecture (or MTV = models, templates, views) and already provide you with a lot of things like CRUD operations in admin pages, ORM, authentication, URL configurations, a template language and much more.
Other Java-based frameworks might differ a lot, and I can't give you a general answer. Depending on the choice, there are only few differences. You can simply choose the language and framework you like the most. I'd recommend to go through some tutorials (Django tutorial, Play! framework tutorial for instance) and look which one works best for your needs.

I want to make a "Web 2.0" application without using JavaScript directly

I'm a full time Java developer of around 4 years, professionally. I'm a GWT fanatic. I love Java. Here's the problem: In my free time I often fall victim to the verbosity of my favorite tools for doing "heavy" development. I also often fall into the trap of obsessively engineering my software. I'll end up with the most beautiful unfinished implementation, ever.
So, here's what I normally work with.
GWT - I use this for dynamic UI and web layout. I love the ease of re-use and it has taught me to absolutely hate javascript. I really can't even bring myself to do much HTML/JS anymore.
Hibernate - POJO to Database, easy-peasy. What i really need from this other than the mapping is that it allows me to have an application that works across multiple databases.
Spring - Mostly security. I've written my own custom LDAP bits for a project.
XML - I've used dom4j and other implementations, including xstreamer. I'd like to use JiBX for XML transport. The problem with this is that I need XML messages that conform to a specific standard rather than being autogenerated. Object->XML->Object are also common enough that it can be a performance bottleneck with large messages (250KB+).
I tried Lombok for a little while and liked it but had occasional issues with it and then I blew up a partition and lost all that work. I don't really feel like doing the same thing again (half the fun was in learning how to do it, now that I know... meh). This taught me why other people want to reduce the explicit code and replace it with an implicit system.
I've been looking into Grails but that runs me into the JavaScript problem (you know, that I don't like it) pretty quickly. I could use GWT with Grails on the back end but I get back into the problem of getting deep in the weeds with GWT. It has also occurred to me that there might be a way to have Grails tags in GSP that are made up of GWT widgets. I'm not really sure how I feel about that.
Another problem I have with Grails is that validation logic before form submission is separated from validation constraints after submission. I don't see how they can be unified (yet) to produce "pretty" front-end validation. I went out of my way to start a JSR-303 compliant validation project for GWT to help solve some of this problem for GWT and really liked the results. It isn't finished but I still find it useful.
So, help me find a better way!
TL;DR - I want to have a Database (and Database-Independent) to GUI solution that allows for dynamic web programming all in one language. Failing that, as close to one language as possible.
TL;DR is TL;DR - I hate JavaScript now, help.
EDIT: I know that it is techincally impossible to do "Web 2.0" development without JavaScript. I'm just trying to not be the guy who has to write it. (Getting a tool such as GWT to do it for me from a language I do like, for example.)
Just learn JavaScript.
Resistance is Futile
...and you will be assimilated.
PD: I'm an ex JavaScript enemy. Now it's my favourite language.
You can certainly develop an entire Web 2.0 project without coding Javascript using GWT (we have), but at the end of the day you still have to know HTML/CSS & Javascript.
This might sound like a stupid statement, but it's not once you consider that GWT is not a perfect abstraction, nor is it designed to be. It wasn't written in Java so that you didn't have to ever code in Javascript again, instead they did it because Java has better IDE's, is statically typed and makes maintenance a hell of a lot easier.
So yes, by all means go with GWT (and check out the new OOPHM, because it's AWESOME) but don't forget that you'll always need an understanding of the underlying frameworks of the web, if you want to develop for the web.
Have you heard of Echo?
It doesn't provide the database part of the problem, but it would work well with any database that you can work well with.
Echo is a platform for building
web-based applications that approach
the capabilities of rich clients. The
applications are developed using a
component-oriented and event-driven
API, eliminating the need to deal with
the "page-based" nature of browsers.
To the developer, Echo works just like
a user interface toolkit.
The latest iteration, Echo3, features
the ability to write applications in
either server-side Java or client-side
JavaScript. Server-side applications
run in any Java Servlet Container and
do not require developer knowledge of
HTML, HTTP, or JavaScript.
You might want to take a look at some of the AJAX powered JSF libraries. IceFaces and RichFaces are both solid.
Been there, done that. I was a GWT developer for 3 years... I started using it in v1.1! GWT is fantastic, and works really well for small applications. But the development comes to a crawl once you it a moderate application size, even if you divide your application in sub-modules.
It is also quite ironic that a UI framework has such limited UI creation tools. :)
Personally I bit the bullet and learned javascript. It isn't as bad as I thought. Especially with jQuery. :)
Obviously there is no perfect framework. But just the fact that GWT has been out for 3.5 years now, and it still largerly ignored in the Java world should tell you something. Since you're doing this on your free time, I would recommend learning the most popular framework: Struts. You'll see its limitation, and also why it is so popular. Of course, you'll need jQuery for that 2.0 functionalities. :)
Take a look at JRapid, a rapid development platform for Java developers. It generates very powerful Ajax enabled UI without the need of coding.
Not sure if you would like this , but have you heard about Haxe?
You might not like it but its AIO (all in one) solution (sort of).
I can understand your dislike of JavaScript and it certainly has its problems but I think your fighting nature at this point.
Web 2.0 is strongly based on JavaScript for a good reason as it provides the ability to perform tasks on the client machine without requiring page loads.
I'm sure there are alternatives but if you want the look and feel of Web 2.0, you will end up doing a lot more work with little reward. JavaScript is the accepted and functional tool for the job.
I'd say stick with GWT and just drink more of the Koolaid. It's a completely awesome development model that seems to be lost on those who haven't tried it.
If you want to improve your GWT experience, jump to the bleeding edge (I work off trunk, it's quite stable) and use the other Google originated projects like GIN, gwt-incubator and Guice. Especially watch Ray Ryan's GWT best-practices Google I/O talk: http://www.youtube.com/watch?v=PDuhR18-EdM
As for the "framework" part: forget 'em. Just use normal servlets and let GWT take care of the RPC for you. Servlets are a pain when you have to deal with JSP and you're own AJAX calls, but when they're only implementing asynchronous app logic, it's not that bad at all. Guice Servlet makes it all quite easy. You can still use a JVM hosted language to write your servlets if you want.
GWT has an incredible advantage over other JavaScript frameworks in that the layer of abstraction it provides allows for major future advances without any changes to your code. If the GWT compiler and browser detection scripts can take advantage of new browser features then you benefit from a simple recompile.
The big annoyance I see in your requirements in XML... hopefully that's just for integration with a 3rd party service and your client-server communication can just be GWT-RPC.
I don't use javascript or ajax, in medium-large application they create a lot of problem with compatibility, because moving some part of code inside client, create security breaches and problem with different browser.
I use only HTML(5) and CSS2/CSS3, and I have a lot successes.
I use this 2 ways:
using "puzzle-techinque". Write a lot of small and simple template (or tiles) to create the big page. I use only JSTL and Spring tag, with Rich/Prime/Ice-faces I encountered a lot of problem with rendering, page building and flow controller, so I discarded them.
using my custom library to parse HTML pages. I create template with my custom grammar, put inside the parser and write on output stream. This is the best way.
If you say me your preferred language and context, I can help you to perform JS-free.

Java for the web

I posted this question: https://stackoverflow.com/questions/418597/java-and-net-for-php-programmer and the answers I was given didn't really help me out.
I read a few of the tutorials at sun.
The basic syntax I understand. The thing I don't understand and really need to (because I think my company is going to tell me start working with this) is to learn how to work with java for the web. I am a php programmer and I did some asp.net c# a few months ago. I am really not understanding how to work with java on the web.
I installed netbeans.
When I start a web project I also get asked what frameworks I want.
I don't know any java frameworks (I do know about spring but never really worked with it).
Is there no simple tutorial on how to do some java for the web??? I never had these much problems when I was first introduced to php :(
Someone help me out, or at least point me in a good direction.
You may find this question helpful.
All you really need to know is HTML, Java, and JSPs.
Creating dynamic content is very easy using JSPs and Java. You also need a webserver like Tomcat or Glass Fish.
As far as the back end Java code goes, there is no difference between that and a desktop application. The only thing that you are changing is the user interface. One of the biggest challenges with switching to a web interface is the fact that it is stateless by design.
The frameworks make web programming easier, they're not required. You can write web applications using plain old servlets and JSPs (with a web application container like Tomcat or JBoss) or even do all the HTTP I/O yourself (obviously that's pointless with Tomcat, etc, around).
A framework like Spring with Hibernate, etc, is similar to frameworks in PHP like CakePHP, they make development easier, they enforce sensible patterns (MVC) upon the programmer, the abstract code that is always going to be done the same way for this type of application. Yes, they limit your choices and abilities, and restrict the actions you can take, to varying degrees. Some are far more heavyweight than others. But there's a lot of choice in the Java world which is a strength, but you just have to spend time evaluating them, and picking one based upon your capabilities.
Take struts and tiles. You can simply use Struts as an MVC system and avoid all of the utility JSP tags it provides. It would take you a short time to rewrite the functionality you end up using yourself, but that's time you don't have, and then there's debugging, and specific domain knowledge and experience that you can't account for.
Are you familiar with MVC? There are multiple frameworks in Java that implement it. Struts is one of the more popular. It may help to start using Struts and work through a tutorial.
This tutorial is a good one that also will introduce you to spring.
This tutorial deals with struts in netbeans
By technical side, you can start downloading Tomcat and code the exercises and documentation.
By "architectural" sie, you code in Java the business logic, that is all the components that take the parameter by communication client-server (request), manipulate this and use this for create the result.
this result is give to communication server-client (response) and it appear, with presentation layer (JSP, etc) in the web page.
The explication is very preciseless and not very "orthodoxe", I know.
It's matter that you understand.
The programming model that is (in most cases) used when writing a Java web application is actually a subset of J2EE. Not a rocket science, but there's a need to know at least bits of it.
Get yourself familiar with concept of J2EE Web Container, J2EE Web application, it's descriptor (web.xml), Servlets (which are, in fact the basic "building stones" of any J2EE webapp) and, of course, JSPs.
Sun has many nice tutorials on their's web pages. Googling any of the above terms with "site:sun.com" usually brings good results (e.g. this one about the concept of Servlets: http://java.sun.com/products/servlet/articles/tutorial/ ).
I'd also forget about web frameworks first, and start with the J2EE stuff, then MVC as a design pattern. After that, go into the web frameworks. Use of a framework is usually of a great help, but even when using one, you still need to know the basics.
Since you're using NetBeans, start with the tuturials they have on their site.
http://www.netbeans.org/kb/docs/web/quickstart-webapps.html
Go through the simple tutorials on the site before you start going into the details on any frameworks.
Java webapps are pretty simple. You have your Java classes (.java) that handle your business logic and your .jsp files that handle the presentation. Try and keep them seperate. You also want to familiarize yourself with the JSTL tags and el (expression language) syntax

Categories

Resources