Recently I've discovered that document upload feature in Alfresco backed with a simple Java Servlet (UploadContentServlet.java). I don't understand why it is a servlet not a webscript. Since everwhere in Alfresco webscripts are used.
Another question which pops up is what's the difference between Alfresco webscript and Java Servlet? They look almost the same, except the procedure to create them and that Alfresco WebScript response could be customized with some ftl template.
Is there any other differences?
As you can find here Alfresco UploadContentServlet, UploadContentServlet is
Responsible for streaming content directly from servers into the repository using the HTTP PUT command. The NodeRef of the node onto which the content will be streamed can be encoded into the URL. In this situation the content of the property can be considered to be updated once the servlet has returned.
It is related to URL addressability, a topic that seems to be discontinued on newer Alfresco versions.
By the way, I think that the reason could be that using a servlet is more efficient especially when uploading huge files.
Mainly webscripts are easier to write and to mantain than servlets. Moreover if you change something in your server side javascript file all you have to do is to reload the container, instead of reloading the context of your application.
This link may show you the architecture Web Script Framework and even if it is quite old the information is still valid for newer versions of the platform.
Ftl templates are very useful and remember that the platform gives you a lot of root objects that you can use in your webscripts.
Related
Go easy please, I'm rather new to the whole web development thing and I'm a little perplexed.
I have the Spark framework installed from Maven, which has Jetty as its underlying web/application server, correct? Jetty is embedded in the Spark jar so I can't/shouldn't mess with it. Is that correct so far?
I read that Spark's embedded Jetty should support rendering of JSP files, however my browser is literally interpreting my JSP pages as text documents. How do I tell Spark/Jetty that it needs to interpret and serve these pages as opposed to just serving them as is?
I'm using Spark 2.5 and the velocity template engine.
Very minimal code so far. Rather than setting up a route to my JSP file I've just been typing the path into my browser while Jetty is running.
I've tested several different minimal JSP files this way.
I added a route in Spark to my JSP file and lo and behold, now it attempts to render the file! I suppose Spark has to handle the interpretation of the string passed to it and Jetty simply serves the content? Beats me! It works!
EDIT: Sorry to bring this back from the dead, but it doesn't have an answer yet and clarity was asked for so.... I added the route using the spark framework in my program, and used the render() function of spark to have Jetty render the JSP file. I had previously been entering the path of the JSP file as a static file, and so Jetty was not interpreting the contents of the file server side (as you would do with JSP) but instead trying to hand the file itself over to the client's browser. Rookie mistake!
I am starting using Liferay Portal and I have two basic needs which I would like to achieve with Liferay.
Is there a posibility to add content to CMS through API level? I would like to insert some data "from code".
More important. How to achieve such situation that for every created user there will be its own homepage generated with some predefined template elements on it?
I have tried to Google something so far, but I did not find it helpful. Maybe some keywords?
After some analysis of documentation devoted to services and ServiceBuilder I realized that it is not what I want.
Let me show an example based on Websphere.
In Websphere we have bunch of EJB components available to perform some actions, exchange information with portal, easy to use. Isn't there any similar mechanism in Liferay not involving web services?
My recommendation for this kind of question is to take a look at the sevencogs-hook sourcecode. The structure of this hook is basically just a long script that runs once, setting up a complete demo site with users, sites, pages, content etc. The code runs once (after the first deployment) and then never again. There are no (obvious) conditionals, no context to understand etc.
You can basically just step through everything and - in that process - understand how content (and pages, images, blog posts, etc.) are created and positioned on pages in Liferay.
This hook accesses the Java API, a very similar API is available through Webservices. Basically all of Liferay's portlets also use the same API to do their business.
Edit: Additional information to keep this answer valuable/current: Sevencogs is discontinued, but still available in old releases (source & binary). The API has slightly changed, so compiling/running it will need a bit of work. James Falkner has blogged about the leftovers and lessons learnt - those snippets are extracted from sevencogs and contain the relevant code pieces to work with the API.
Looking at this page from the documentation: It smells like a SOAP interface (they mention some sort of document uploader service and I've read axis).
You'll find some url examples that should give a list of available webservices.
For number 1, you can use the one of the:
JournalArticleLocalServiceUtil.addArticle()
methods to programmatically add Liferay Web Content from a portlet. If you download the Liferay Portal Source you can see the structure of these methods.
For number 2, can create page templates with preconfigured portlets on them (through the Plugins-SDK), and then use the API to programmatically create the pages using one of the:
LayoutLocalServiceUtil.addLayout()
methods.
If you have any more speific questions about these comment back, and I hope this helps!
i was looking for similar title here but i didn't find much info, so if anyone can provide some example or url or any approach how to do it.
For example: is it possible to call a jsp from a gwt widget?
or communication (server - jsp) in gwt project and so on..
Is there any limitation is using jsp in gwt project?
Thanks :-)
GWT compiles down to html+javascript (static files), while JSPs are internally compiled and behave like servlets. You can configure URLs to point to both (via your server config and/or web.xml).
Both GWT and JSP allow you to go to a new URL. In GWT you can use Window.Location.assign(url) (this will load new URL and close current GWT app).
Additionally GWT allows you to load data by making XHR calls to URLs: http://code.google.com/webtoolkit/doc/latest/tutorial/JSON.html
So:
Yes you can goto JSP pages from GWT app.
Yes you can load data provided by JSPs into your GWT app.
In any jsp applications actions lead to URLs. The URL can point to a GWT module.
You will find applications which offer a back-end for the administrator in GWT, while the front-end runs in Struts2. Konakart e-shop is such an example.
My impression is that GWT will replace the other frameworks on the long run. Everybody will want Rich Internet Applications very soon.
On the other hand in the early 80's i was thinking that in very few years everybody would be using Unix, which never happened, but Unix did quite well after all...
i will develop a web application to view and analyze log files from both remote machines and locally and planning to use java. At first glance it seems like application must work with big data sets effectively. For example to list a log file on browser i should implement a paginated list working with ajax (server will give data accordingly with current page number). Also i like to use AJAX.
My question is how should i design an application like this. i have three possibilities:
AJAX with RESTful service.
JSP and servlet
JSF with AJAX
I would suggest you have a look at Chainsaw - http://logging.apache.org/chainsaw/index.html - and Lilith - http://lilith.huxhorn.de/ - to see how others have approached this.
The released version of Chainsaw is pretty old - a MAJOR update will be released shortly. If you want to try out a pre-release version, you can see a screenshot and get the tarball or Mac DMG here:
http://people.apache.org/~sdeboy/
I am working on a project which is basically a Java application with an embedded IE browser (using JDIC 0.9.5) to display custom HTML files (stored locally that I created). I have a test HTML file with a JavaScript function that checks a simple form with checkboxes and alerts the user with a dialog stating which checkboxes are checked.
My question is, is there a way for my Java application to do the same procedure on the embedded HTML form instead of using JavaScript. I want to keep my application and HTML files simple without the clutter of JavaScript in my HTMLs or a pile of .js files.
Thanks for any help and guidance!
You have two options. Either shift the project to run the Java on the server side using JSP technology inside a web container like Apache Tomcat or Jetty, or write you web page to open up a Java applet.
The applet route allows you to run the code on someone else's machine, and as a trade off you will have to run the application in a strongly security constrained environment. After all, if someone were to run code on your machine, you wouldn't want it able to access your disk, etc.
The JSP solution will have you running the code on the same machine as your web server, since you (probably) control your own web server, the code will not be ran with as many security constraints enabled. This means the code can make requests to other machines, write and read files, etc.
You could replace your model with a client-server model using Java Server Pages (JSP).
If you are displaying the page through an embedded browser it is very unlikely that you will be able to get access to the DOM via Java.
One option is to use GWT javascript compiler to code in java and then convert to javascript. If it will only use IE, then you will only need to keep one of the generated .js files, so the clutter will be low.
Since you're embedding your HTML files in your own Java program, I would recommend you to use one of these 2 approaches:
1.- Use Javascript and structure the files cleanly, is not that complex.
2.- When you do the POST check the values in your Java code and return a new dynamically generated HTML file with needed info
I sincerely recommend you to follow the first option. Other options to work with Java in HTML would be JSP or GWT, but both will require a proper J2EE server, which would be overkill in your application