-1

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!

  • You want to use servlets – Scary Wombat Oct 30 '19 at 06:52
  • PHP is about as object-oriented as JS - meaning that both support writing in an object-oriented way, but most of the code written is not very object-oriented. If you are thinking in that direction I would check whether PHP is allowed. If you're using Java, you could use JSP pages, or a templating engine (Thymeleaf for example) to generate the HTML; generating them directly in Java code isn't very productive. – Erwin Bolwidt Oct 30 '19 at 06:52
  • Yes, you can do this using servlets, just poke around here and Google and you find many examples. – Tim Biegeleisen Oct 30 '19 at 06:53
  • There is GWT, which is a Java framework. Not necessarily my favorite, though – Stultuske Oct 30 '19 at 06:56
  • You can also try to read about spring framework. Makes your development faster and it is very easy to use. https://spring.io/ – Royts Oct 30 '19 at 06:58
  • Asking for tools, libraries, tutorials, or off-site resources recommendation is off-topic in here – Andreas Oct 30 '19 at 07:01
  • 2
    Spring Boot may be a good choice. – MC Emperor Oct 30 '19 at 07:02
  • Spring Boot for back end, Vaadin for front end and everything is in Java then. – Markus Kauppinen Oct 30 '19 at 07:19

2 Answers2

0

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:

  1. 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)
  2. 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)
  3. 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)
  4. 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).
Christian Frommeyer
  • 1,390
  • 1
  • 12
  • 20
  • I may add JSF for server side or YUI for client side l. I know, considered obsolete, but good examples of using OOP in web apps. – gusto2 Oct 30 '19 at 07:38
0

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:

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!

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216