HttpServlet in IBM Java? - ibm-cloud

I'm trying to build an app using IBM Bluemix that takes user input in an HTML form, processes it in a server-side Java application, and returns the processed data to the user. This kind of thing is really simple to implement using HttpServlet, but that class doesn't seem to exist in IBM's jdk. Where can I find this class?
Apologies, I'm very new to any web development concepts beyond building a static HTML website.

HttpServlet is not part of the Java Standard Edition runtime, it's provided by your application server--Tomcat or WebSphere Liberty, for instance. At development-time, you'll need one of these on-hand to provide you that class to compile against.

I presume you are using "Liberty for Java" runtime. I believe HttpServlet is part of Liberty, and the default configuration of Liberty runtime includes the "servlet-3.0" feature (see here). There's also mention of it in the Liberty documentation here. So you should be able to use it in Bluemix.

Related

File handling in GWT(at server side)

I have some doubt regarding gwt file handling.
How to do file handling in gwt(at server side). How to create simple file. I mean which class is particularly used for CREATING and HANDLING it ??
Where is the file created. Is it under server package or somewhere else ??
How to resolve serialization and serialization problem. ??
GWT is a client-side technology. It's server-agnostic (and can also be used client-only, e.g. mobile apps, Chrome apps, browser extensions). GWT-RPC and RequestFactory use Java servlets by default (nothing precludes implementing RequestFactory in other languages/technologies) but have otherwise no requirement or limitations.
So, server-side, it's all just Java in most of the cases, and depends on your deployment target (e.g. AppEngine restricts what you can do, servlet containers can also have security policies in place, and you're of course dependent on authorizations at the filesystem level)
Since GWT is a pure client-side technology you have all possible options like plain Servlets for example. You are not limited in any way in picking the upload approach.
However, there is a number of open source projects, which make possible to use nice features like progress bars and multiple file uploads. And those come integrated with some GWT widgets as well. Check this project for example http://code.google.com/p/gwtupload/

Developing a Java based web service client

I have a couple of web services running on JBoss 5.1.0 GA with JBossWs native stack (shipped with JBoss 5.1.0 GA binary)
These web services are simple POJO services. Many of the WebMethods exposed by the services are of Complex Object type (I call these Complex types as DTO's) and a lot of custom defined exceptions. These DTO's are also bundled in a jar file, so that they can be used at the Client end as well.
I started creating a client using Eclipse (which I understand is using wsconsume to generate the client stub) and I saw that the utility would generate the DTO's from the WSDL and I could not find any way of enforcing the utility to use the DTO & exception classes provided in the jar file.
I had earlier asked a question on this on SO and could not find any answers.
From reading of various resources on wsconsume and generating client stub using eclipse (which would use JBossWS) i have now started to believe that what I am trying to achieve might not actually be possible using wsconsume.
My question is:
Is there a better way to create a client stub which would use the DTO classes from the jar files. I am open on changing the Client generation mechanism and move to axis or any other library for Client generation if that is possible. It would also be ideal if an ant task can be created for Client stub generation.
PS: My knowledge on web services is very limited and if I am being stupid with my question here, please pardon me for that.
Why do you want to use Data Transfer Objects in Your Web Service ? Is that necessary? Because If you use such objects, those web services can be use only in Java I think. That is a interoperability issue. So If you can avoid those kind of objects that will be a good practice.

Recommendations for a Full-stack Framework for REST?

I am looking for a robust REST framework to eliminate all that boilerplate code with starting up a new REST-only web service (mobile clients). Is there a framework that already has this built-in where I could, for example, simply build the domain models and run with it? I would like to see:
Authentication & User Model
Logging
Basic CRUD
Permissions (for model access)
Scalability
It seems every web service at a minimum needs the above capabilities. Somebody, somewhere must have written a good re-usable framework with the above capabilities. Any ideas? I would prefer Node.js, Java or even hosting with a PaaS service provider that offers these features.
Spring 3 MVC provides a very nice and simple annotation based framework for REST.
See http://blog.springsource.org/2009/03/08/rest-in-spring-3-mvc/ it can be deployed on any java web server like Jetty or Tomcat.
A framework like XAP provides a combined solution of Spring and Jetty plus it's built for dynamic scaling.
See http://www.gigaspaces.com/xap.
Last if you want to easily on board this solution on any cloud CloudifySource provides an open source project which includes XAP capabilities and PaaS.
See http://www.cloudifysource.org
I use Symfony 1.4 for this. It is an PHP framework. It generates most of what you need for free. The database stuff is also quite easy as the Symfony uses ORM libraries (you can choose but I can recommend Doctrine: http://www.doctrine-project.org/).
For example the whole backend site(admin) generating is a matter of running one command. They have a great e-book fro free. More info here:http://www.symfony-project.org/.
There is also Symfony 2.X (http://symfony.com/), which have a lot of new features (e.g. new Doctrine 2.0). Especially with the bundle (plugin) https://github.com/FriendsOfSymfony/FOSRestBundle is the RESTful service quite easy.

What does a portlet bridge do?

In an interview today I mentioned that I had done some jsf work in a portlet. The interviewer asked for specifics on what the portlet-bridge does. I never looked into it all that much, just used it because I was told it would make jsf work in the portlet. All I could really say was that it allowed the requests to come from the portal to jsf in a way jsf would understand, and made it play nice.
What exactly does the portlet-bridge do?
From the spec linked by Jeremy Walton above.
2.1 What is a Portlet Bridge?
The Java™ Portlet Specification
defines a set of APIs for directly
implementing a portlet. A portlet
bridge is a technology used by a
portlet to bridge to an execution
environment where differing
abstractions are used for rendering
markup or processing user
interactions. Typically these are
well-known, possibly standard web
development environments. Examples
include JavaServer™ Faces and Apache
Struts.
The portlet bridge acts as the
translation engine between the portlet
environment and the targeted system.
It expresses the portlet request
context to the bridged environment,
executes the request and transforms
the response as appropriate for the
portlet environment. It provides an
abstraction of the portlet environment
for the bridged environment, and for
developers working within the bridged
environment. These developers are
freed to execute Faces views as
portlets, without the need to
understand the details of the portlet
APIs and development model.
To put it simply, a portlet bridge is
the technology that allows a Java web
developer to execute views developed
using other web programming
abstractions as portlets without
needing to know and or learn about
portlet development, concepts, or
APIs.
The Portlet Bridge for JavaServer™
Faces is the specific bridge
technology needed to support this
bridging behavior for JavaServer™
Faces.

JavaBeans Activation Framework: is it worth learning?

Recently I've stumbled upon a class named javax.activation.DataHandler. But while reading the javadoc of JDK6, I was not able to understand the aim and rationale of the framework. If you have have used the framework in real life project, please share your experience and explain what a developer can "earn" from it.
I used it in a JAX-WS web service using CXF for streaming of attachments with MTOM:
#XmlMimeType("application/octet-stream")
private DataHandler data;
A JAX-WS generated client will use the class too. From that class you can access the underlying input/output streams as required. When calling a web service method which includes a DataHandler, clients can write to the OutputStream, and on the server side, you can read from the InputStream. This way the data is never buffered in memory on client or server.
I'm sure there are other uses for this class, but this is only one that I've come across.
So is it worth learning? Well it was for me.