I was looking for real information about this, I am working some system on Java EE, I worked all my life on web, now I am getting into systems, my boss told me he makes javascripts works from "server side" to manage polls and stuffs, still I didnt think was right and I told him I thought javascript was only executed client-side, still seems like its right, I found both information about saying it is possible and it is not, anyone has some valid answer about this? and if yes, how is this possible?
Thanks!
You can indeed execute JavaScript on the server-side with third-party packages like node.js, Mozilla Rhino, or similar.
However, it's unclear to me from your description whether he wants you to actually execute JavaScript from the server-side, serve JavaScript content from the server-side, or use AJAX to make remote-procedure calls to server-side code.
The scripting API is in the javax.script package available in the Java SE 6 platform.
Refer Link :-
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/
You can execute javascript on server side too which means that develop server centric code on server side for etsblishing connection, serving HTML files etc.All these things can be done on using server side javascript.There are so many frameworks that are used to achieve this.The main objective of running serve side javascript is to execute server side functionalities.One such example is maintinaing long-lived connections with the client.
Nod.js is such a framework which is used to implement the above said functionality.Apart from this, there are other server side javascript frameworks as well.RhinoJS is can be used to execute execute javascript in server side when running in a Java Virtual machine.
However,the idea using the server side javascript frameowork will vary depending upon your requirements.
Related
I know this question is very basic, but it was already asked and it doesn't have a very complete answer, actually it's just a comment:
How to make a Processing Sketch with external libraries and files work on a website?
So, i know this doesn't work on PHP servers, but what if I have a java hosting? Would it work then? It would be useful to know before buying : )
Please understand the difference between something running on a server and something running on a client. The question you linked to isn't asking about a server at all. It's asking about running a Processing sketch in a browser, not on a server.
What kind of server you're using doesn't matter if you're just trying to run stuff in the browser. You just need a basic file server, and there are many free options. I personally like GitHub Pages.
You'll need to use Processing.js or P5.js to deploy your Processing sketch to a webpage. I wrote a guide on the differences between these Processing versions here.
If you are really asking about how to run Processing on a server and not in a browser, then see this page: https://github.com/processing/processing/wiki/Running-without-a-Display
I know this a fairly common question but after reading a lot I still can't understand this concept.
What I understand so far is that the main difference about a server side and a client side language is that the first one needs to be interpreted by the server to be sent to browser and the second one doesn´t.
I've worked with Vaadin and I know that is a server side framework because the java code needs to be interpreted to HTML and Javascript to be sent to browser. But then I've read that GWT is a client side and I can't understand why because we design all the page elements with Java widgets and they need to be interpreted to HTML and Javacript right? So, shouldn't GWT be a server side framework?
And what about JSF? I'm working with Primefaces and I develop xhtml files that uses beans to get server information. That means that the xhml files are client side and the Java beans are server side right?
Thanks!
It's not about the language the code is written, it's about where it runs.
GWT is a client-side technology just like TypeScript or CoffeeScript: they first have to be compiled or transpiled (a true compilation in the case of GWT) to JavaScript. The compilation has to be done at build time, before you deploy the app to your server. Once compiled to JavaScript, you don't need a server: the scripts can be packaged into browser extensions, mobile apps, or just run out of the filesystem (or be deployed to a Node.js server to run as server-side code !).
You can draw a parallel with Dart: dart2js converts Dart code to JavaScript so it can run in the browser, and/or you can run Dart code in a DartVM on the server side.
JSF is a server-side technology: things run in the server and generate code (HTML, JavaScript, CSS) to be interpreted by the browser (client).
I can't really tell for Vaadin as I don't know its architecture. If GWT Widgets have to be compiled upfront, then it'd be a server-side technology, generating highly dynamic web pages (so they could even run offline). If it compiles GWT widgets on-the-fly, then it'd be a bit in between; but it's primarily a server-side technology.
Vaadin use GWT to keep client-side code base in Java. GWT compiles Java code into browser dependent JavaScript. Without GWT all code should be written in JS. Vaadin is RIA application framework, so managing complex widgets code (look into Table source code) with pure JavaScript would be painful and not easy. You can write some logic in client side and also you can use pure JavaScript in Vaadin7. It's easy to extend and gives solid foundations to write good and rich UI with minimal use of the JavaScript.
I am new to java web development.
Currently I'm learning technologies such as Servlets, Jsp, and Java Frameworks like Spring etc.
I was wondering that as an end user say for a java web-site without applets, would the user of the website be required to install java in his/her machine?
Because it seems that in the case of Servlet and Jsp all execution is done at the servers end and only the result is sent back to the user in html format.
Please correct me if I'm wrong.
As you suspect, Java is only run on the servers. It is the language that accepts an HTTP Request and processes it, issuing out an HTTP Response. As with most good coding practices, this means that the server program is returning a response that is, essentially, text. The implication here is that you can write the server in any sort of programming language, or set of languages, without the browser needing to know what or why.
Thus, the browser is agnostic to the languages you use on the server.
Java Applets are different; they are compiled Java code that is downloaded by the client and run inside a local JVM. For this to work, the client requires Java to be installed. Applets can be quite small - invisible even - and thus malicious sites can use them on unsuspecting browsers to do wonky things. For this reason people are concerned about Java security holes that would allow applets to do more than they should.
You are correct. The java is executing on the server. The user would only have to install java if the application served applets, which as you say, is not the case here.
No need to install java at end user(client).
Because HTML renderkit return html format.
But if his or her need to developed , java is need.
hi you need to install jdk if you want to develope any java project,the jdk itself contains jre( java runtime environment),,
you can prefer below link
http://www.journaldev.com/546/difference-between-jdk-jre-and-jvm-in-java
You do not need your client systems to have Java installed.
The news about disabling java in web browser was due to some security vulerabilities in the current release (which Oracle said they will fix in October release). But you do not have to worry about it since you do not have applets in your web site. The clients would need java jre installation if you have such plugins as applets
Http is a stateless and text based protocol. That means Http protocol is not able to remember its previous state and this can not hold any state of execution.Its a text based protocol so medium of exchange of information or data over this protocol is text.
Main issue with this protocol is that it can handle only one request at a time and send response to user in same manner. But in current time user requirements have changed dramatically. So Http can not handle so much requests at a time as well as cant managed to send multiple response. So Here Java EE and web servers comes into effects
Web-servers provide an environments where a web-applications(servlet,jsp,Java EE) can run,executes and send responses to the client. Web- servers perform task such as:
1: Handle a Http-requests and in the same way send the responses to that requests.
2: Since, Http protocol only understand text so , Web-server parse the request as a text,then process it and then transform that response again into a text and send it to the client server.
3: Provide an environment where web-applications ,request-response and other services can run flawlessly,dynamically and with strong security undergo.
4: And last but not the least, these web-servers are designed and developed in pure java and run it thread-model so you trust your application is in safe hand.
And applets runs in different way, client side at least need JRE to provide an environment to executes an applets. Applets are differs from web-technology.
I have a ajax frontend for my java backend, and to make things work with the crawls and HTML5 pushState I going to use HtmlUnit to process the javascript in every first request.
I can make a workaround with a Filter to not use HtmlUnit trying to reduce the server load.
Regardless of browser compatibility, which is best for the server?
After a lot of research and test I can tell that process heavy javascript applications on server side ins't I good idea, HtmlUnit is the best tool around and it doesn't do the job very well, so if your requirements are to support clients that doesn't support javascript, so go for PHP or some other server side script language or maybe JSF.
I my case, I have a Back-end in JAX-RS and I manage to support HTML5 pushState without process the javascript on server-side and assume that the client process javascript, HtmlUnit still in use for enable crawlability.
I have a problem relating my web project.
Previously when my professor ask me on doing a online judge application, I chose to implement it using php rather than Java servlet, as I thought java servlet quite complicated.
Then problem comes. For the online judge, I have to use a backend java program on the server to do the processing of user submitted codes. That is, each time a user submits something, php would call the java virtual machine and invokes the java application. However, to invoke the java application, my own way now is to use command line
popen("start java -jar \"$FILE_ROOT/OnlineJudge.jar\"", "r");
This works fine, but considering loading of java virtual machine, it is actually very slow and error prone. So I was wondering if there is any better ways for PHP to invoke local java programs on the server. Because later I found I still need to invoke more java from php.
Any idea would be appreciated. Thanks.
have you considered php-java bridge, this is quite useful, it uses XML to communicate between php and java.
You'll need to start the JVM once and the bridge component will help with communication.
here are some examples, here you can find a simple example to connect php and java
Depending on how the java application is written, it likely wouldn't be too hard to convert it to a servlet. Once it is a servlet, run it under jetty or tomcat, and then just have your php connect to it via CURL and put/get data from the servlet.
Java servlets are fairly simple. If you are using an external framework like Spring it becomes even easier, but if not, you just need to extend javax.servlet.http.HttpServlet, and then configure it in your web.xml.
It's a bit of a hack, but shouldn't take you too long to accomplish.
Also take a look at the exec for command line executions. I used it to shut down my computer after doing an extensively long task well into the night.