wood burning stoves 2.0*
The moose likes Portals and Portlets and the fly likes Need Help for creating Java portlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Need Help for creating Java portlet" Watch "Need Help for creating Java portlet" New topic
Author

Need Help for creating Java portlet

Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Hi All,
I am new in the Java Portlet.

I want to know the setps for creating the java portlet in eclipse & how will i run it through tomcat.

please give the guidline for creating & testing the HelloWorld Portlet.
Its very Urgent.

Thank you in advance.
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Hi ,

You can not run a portlet in a Tomcat. You need to have a Portal container (just like servlets needs a servlet container, A portlet needs a portlet container). There are so many open source implementations of Portal containers available like Liferay portal, JBOSS Portal , Jetspeed ..etc.

If you want to run only on Tomcat, then download "Liferay bundled with tomcat" from Liferay website. Its easy to configure and run.
To develop a portlet in eclipse, you can install the portal pack plugin for eclipse. I dont remember the url but you can search in google for "eclipse-portal-pack" easily.


Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Thank you very much for you reply.

I have another query,

can i integrate the already developed web application into Liferay Portlet?
If it is possible,then how can i do that.

Please Help Me.
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
In "LiferyaBundle with tomcat", the liferay product is integrated as default web application inside tomcat container (in /ROOT). You can also deploy your web applications inside the tomcat and access with your context path.

But to access your web application pages, inside a portal page, you need to have a portlet. The portlet should access your application (cross-context).

In the portlet doView() method , generally we'll dispatch the request to a jsp page (view.jsp). From view.jsp, you can redirect to your webapplication .

Regards
Prashanth
Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Thank you Prashant.
Could you please give me one example?

Lets take an example of HelloWorld which is Java web application which is developed in JSP 7 Servlet.

How can i access these helloworld application in Liferay portlet?
What changes needs for accessing this application in liferay?
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Hi Tukaram,

You deploy the war file of your webapplication in the tomcat(or any server) where the Liferay is running. Now from your portlet (view.jsp), you can access the content of your webapp using cross context include like <c:import url="relative url to your webapplication resource" context="your webapplication context name" />

For this, you need to enable cross context for your portlet war file in the tomcat server.xml as shown below :

Assume that your JSR portlet is deployed in Liferay as MyFirstPortlet.war file and your webapplication (servlets and JSP) is deployed as "MyWeb.war"



Suppose you have a TestMe.jsp in MyWeb.war and you need to access this inside the portlet, Then, in your portlet (view.jsp),


This is a very basic example. Hope this is what your requirement is .
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
I couldn't attach the war/zip files here. Let me know your mail id .I'll send
Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Thanks Prashant,

Mail ID = kanade_tukaram@rediffmail.com

enable cross context part is not getting.

could you please help me regarding this issue.

Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Hi,

By default Tomcat will not allow access to the resources of one web application in the other web application. We need to mention in the server.xml (TOMCAT/conf/) file for which web application we want to enable this cross context access.


Here I am trying to access a jsp of another web application in my portlet (my portlet is also a WAR file), so added that entry in the server.xml (before closing tag of </HOST>).

I'll send you both the war files.

I assume that you know how to deploy a portlet war file in liferay. You can simply copy the portlet war file into the hot deployment directory (on windows it is <your home dir>/liferay/deploy). If you start the tomcat, the liferay will pick this war file automatically. Thus you can deploy your portlets dynamically.

Regards
Prashanth
Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Hey Prashant,
Thank you much for your valubale help.

I will check it out.
For testing this application should i require jstl.jar & standared.jar files.

I will give you replay.

Once again thanks.

I had another query

Can i integrate GWT application with the Liferay Portlet.
If i can then how will i do that?
could you please help me regarding this GWT application.
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Hi Tukaram,

As we are using the JSTL tag libraries in the jsp, we need these jar files.

I dont have much knowledge on GWT. But Liferay portal is a pure java implementation. So you can integrate with GWT too. I'll also try to do that and let you.

Regards
Prashanth
Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Ok, once you do that please let me know.

I am also trying for that & let you know once it get completed.

These two jar files need to be put in the MyFirstPortlet lib folder.

Am i right?

Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Hi Prashant,
I have not recived your mail.

Please send me the war files, i am waiting for your mail.

Thanks
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Sorry for that, I sent you now.
Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Hi Prashant,

Thank you so much.

Its working now.

can i get good books or any material for Liferay Portlet.
Tukaram Kanade
Ranch Hand

Joined: Feb 18, 2010
Posts: 39
Hi Prashant,

Could you also send me the war file of JSP/Servlet Project?

Thank you.
radmadsad bad
Greenhorn

Joined: Aug 23, 2010
Posts: 3
Hi prashant and tukaram,

I would really appreciate it if you can send me a copy of the web application to my email id as well. I have been trying to do this since a couple of days. Had no luck.
Thanks,
MY email id is
rguli747@yahoo.co.in
thanks
 
Consider Paul's rocket mass heater.
 
subject: Need Help for creating Java portlet