Porting Servlets to Portlets
Hi,
I want to port a servlet application to a portlet application. In particular, I want to port this method, which works with Servlets so that it works with Portlets:
public void jasperReport(String name, String type, ResultSet data, Map params) {
// Look up the compiled report design resource
ExternalContext econtext = getExternalContext();
InputStream stream = econtext.getResourceAsStream(PREFIX + name + SUFFIX);
// make sure cursor is in front of the first record
try {
data.beforeFirst();
} catch (Exception e) {
throw new FacesException(e);
// Fill the requested report with the specified data
JRResultSetDataSource ds = new JRResultSetDataSource(data);
JasperPrint jasperPrint = null;
try {
jasperPrint = JasperFillManager.fillReport(stream, params, ds);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
} finally {
try {
stream.close();
} catch (IOException e) {
// Configure the exporter to be used, along with the custom
// parameters specific to the exporter type
JRExporter exporter = null;
HttpServletResponse response = (HttpServletResponse)
econtext.getResponse();
FacesContext fcontext = FacesContext.getCurrentInstance();
try {
response.setContentType(type);
if ("application/pdf".equals(type)) {
exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,
response.getOutputStream());
} else if ("text/html".equals(type)) {
exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER,
response.getWriter());
// Make images available for the HTML output
HttpServletRequest request =
(HttpServletRequest)
fcontext.getExternalContext().getRequest();
request.getSession().setAttribute(
ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,
jasperPrint);
exporter.setParameter(
JRHtmlExporterParameter.IMAGES_MAP, new HashMap());
// Requires mapping /image to the imageServlet in the web.xml
// This servlet serves up the px images for spacing
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
// Enough with the preliminaries ... export the report already
try {
exporter.exportReport();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
// Tell JavaServer Faces that no output is required
fcontext.responseComplete();
Thanks,
Marc
Message was edited by:
marc_nikko
so go ported! Please don't expect people to do work for you here.
If you have problem describe it. If you need where to start google portlet, and if you are still lost on where to begin, be kind and ask "where do I start" here.
Similar Messages
-
Convert existing servlet into portlet
Hi
We have a set of Java servlets running on apache and jserv and not using Portal. My task is to be able to convert these into Portal.All of the existing servlets are extends/use our existing set of classes. They display a list of rows in a table as HTML with a URL pointing back to the same servlet or different servlet based on logic, with set of parameter. With my current setup (all on a Win2000 system), I have installed the JPDK samples and it is working fine, but have now got stuck in applying the concepts to my own existing servlets. So can you help me how can i convert an existing Java servlet into Portal?
First i tried the "how to build your own java portal exercise" and it runs fine. But when i tried to run simple servlet to convert into portlet, i got the following error. I am really confuse about Renderer. Is it nessessary to make Renderer or use Default Renderer? I will really thankful to you if you give me some idea.
I changed the following in to conf/jserv properties.
1. set the " <showPage class="AgeServlet"/> " in provider.xml
2. in zone property
servlet.AgeServlet.code=oracle.portal.provider.v1.http.HttpProvider
servlet.AgeServlet.initArgs=provider_root=C:\MyProvider,sessiontimeout=1800000,debuglevel=1
3. In jserv property
wrapper.classpath=C:\MyProvider\MyClasses
Where i put my AgeServlet.class
4.Stop and Start the Oracle HTTP Server.
When i try to run url(http://host.domain:port/servlet/AgeServlet) it gives me following error.
Error!
javax.servlet.ServletException: Unable to initialize new provider instance: java.lang.reflect.InvocationTargetException
My servlet is
// JDK1.2.2 module
import java.io.*;
import java.util.*;
//JSDK modules
import javax.servlet.*;
import javax.servlet.http.*;
* class to promt for the year of birth
* and calculate the age.
* @author Vipul Patel [email protected]
public class AgeServlet extends HttpServlet {
* method to call doPost
* @param request
* @param response
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);
* method to call calculateAge
* @param request
* @param response
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
getAge(request, response);
* method for display html form for get year
* and calculate the age
* @param request
* @param response
public void getAge(HttpServletRequest request,
HttpServletResponse response) {
response.setContentType("text/html");
PrintWriter out = null;
try {
out = response.getWriter();
} catch(IOException ex) {
ex.printStackTrace();
String age = calculateAge(request, response);
// create and send html form to user
out.println("<html>");
out.println("<body>");
out.println("<title>Age calculation</title>");
out.println("<form action=\"/servlets/AgeServlet\" method=get>");
out.println(age + "<br>");
out.println("Enter the Year of Birth<input type=\"text\" name=ageyear><br>");
out.println("<input type=submit value=submit>");
out.println("<input type=\"reset\" value=\"reset\">");
out.println(" </form>");
out.println("</body>");
out.println("</html> ");
* calculate the age
* @param request
* @param response
* @return age
public String calculateAge(HttpServletRequest request,
HttpServletResponse response) {
String age= "";
String year="";
int curr_year;
int count_year = 0;
year = request.getParameter("ageyear");
Date date = new Date();
String today_date = date.toString();
today_date = today_date.substring(24,29);
curr_year = Integer.parseInt(today_date);
if((year != null) && (!year.equals("")) ) {
int get_year = Integer.parseInt(year);
if(get_year > curr_year) {
age = "You enterd wrong entry!!!!!";
} else {
for (int i=get_year; i<=curr_year; i++) {
count_year++;
age ="Your age is: " + String.valueOf(count_year);
} else {
age = "Enter the year of Birth";
return age;
Thank you very much!!
Vipul Patel
nullHi
Now i changed my code and it display my contents on broweser. But when i submit the form i cannot able to forward my request to same page. Any suggestion please.
Thanks.
changed code
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import oracle.portal.provider.v1.*;
import oracle.portal.provider.v1.http.*;
public class AgeServlet extends HttpServlet {
* Initialize global variables
public void init(ServletConfig config) throws ServletException {
super.init(config);
* Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
doGet(request,response);
* Get Servlet information
* @return java.lang.String
public String getServletInfo() {
return "AgeServlet Information";
* Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
PortletRenderRequest pr = (PortletRenderRequest)request.getAttribute(HttpProvider.PORTLET_RENDER_REQUEST);
try {
renderShow(pr);
} catch (Exception e) {
private void renderShow(PortletRenderRequest pr)
throws PortletException {
try {
/*HttpServletRequest request = (HttpServletRequest)
pr.getAttribute(HttpProvider.SERVLET_REQUEST);
HttpServletResponse response = (HttpServletResponse)
pr.getAttribute(HttpProvider.SERVLET_RESPONSE); */
PrintWriter out = pr.getWriter();
pr.setContentType("text/html; charset=WINDOWS-1252");
pr.setContentType("text/html");
//PrintWriter out = response.getWriter();
// create and send html form to user
out.println("<html>");
out.println("<body>");
out.println("<title>Age calculation</title>");
out.println("<form method=\"POST\" action=\""+HttpPortletRendererUtil.htmlFormActionLink(pr,PortletRendererUtil.PAGE_LINK) +"\">");
HttpPortletRendererUtil.htmlFormHiddenFields(pr,PortletRendererUtil.PAGE_LINK);
String ageParam = HttpPortletRendererUtil.portletParameter(pr, "ageyear");
String submitParam = HttpPortletRendererUtil.portletParameter(pr, "mySubmit");
out.println("Enter the Year of Birth<input type=\"text\" name=\" + ageParam + \"><br>");
out.println("<input type=\"submit\" name=\" + submitParam + \" value=\"submit\">");
out.println(" </form>");
out.println("</body>");
out.println("</html> ");
if (pr.getParameter(submitParam) != null ) {
out.println("You are "+ calculateAge(pr,out));
} catch (Exception e) {
* calculate the age
* @param request
* @param response
* @return age
public String calculateAge(PortletRenderRequest pr, PrintWriter out) {
String age= "";
String year="";
int curr_year;
int count_year = 0;
year = pr.getParameter("ageParam");
Calendar rightNow = Calendar.getInstance();
curr_year = rightNow.get(Calendar.YEAR);
if((year != null) && (!year.equals(""))) {
int get_year = Integer.parseInt(year);
if(get_year > curr_year) {
age = "You enterd wrong entry!!!!!";
} else {
count_year = curr_year - get_year;
age = String.valueOf(count_year);
} else {
age = "Enter the year of Birth";
return age;
Error message
Wed, 08 Aug 2001 00:04:55 GMT
No DAD configuration Found
DAD name:
PROCEDURE : !null.wwpob_page.show
URL : http://ntserver:80/pls/null/!null.wwpob_page.show?_pageid=null
PARAMETERS :
===========
ENVIRONMENT:
============
PLSQL_GATEWAY=WebDb
GATEWAY_IVERSION=2
SERVER_SOFTWARE=Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.24
GATEWAY_INTERFACE=CGI/1.1
SERVER_PORT=80
SERVER_NAME=ntserver
REQUEST_METHOD=POST
QUERY_STRING=_pageid=null
PATH_INFO=/null/!null.wwpob_page.show
SCRIPT_NAME=/pls
REMOTE_HOST=
REMOTE_ADDR=172.16.0.27
SERVER_P ROTOCOL=HTTP/1.1
REQUEST_PROTOCOL=HTTP
REMOTE_USER=
HTTP_CONTENT_LENGTH=52
HTTP_CONTENT_TYPE=application/x-www-form-urlencoded
HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) RPT-HTTPClient/0.3-2S
HTTP_HOST=ntserver
HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
HTTP_ACCEPT_ENCODING=gzip, deflate, x-gzip, compress, x-compress
HTTP_ACCEPT_LANGUAGE=en-us
HTTP_ACCEPT_CHARSET=
HTTP_COOKIE=portal30=3.0,en,us,AMERICA,7044103775205D94AE891C2EB8EC88ECB9671CC56E5524FFBAE3419299B938639A5159BD1DF60D6A57362DA77173DED757521073FAB521072C6E83A9EDD32D5DD1E3859A48A75
9C1537468FDD6B2AF6C36692DA501614F9B;
portal30_sso=3.0,en,us,AMERICA,C62FD25D23E9A2D66948EDCD463B2CCD50050AD8D02B7EF55A61DBC14E253387C44B1A5D9668CC141CE38DD4455FEF3D28188817CC1678D8F0C1F642C95CB0E34406EFC41D4A36E1A2915
182A5FC121377E258FA76480763
Authorization=
HTTP_IF_MODIFIED_SINCE=
HTTP_REFERER=
null -
Reuse servlet as portlet- limitations??
I reuse servlet as portlet, by registrating the "portlet" and adding the line servlet/servletname in a provider.xml file.
My questions is, how this limit the portlet. What's the difference between a portlet and a servlet acting as a portlet. And what's best practise if you want to use a servlet as a portlet?!
Thanks!There are a few differences between a servlet that runs on its own (in stand-alone mode), and a servlet that runs as a portlet.
Some of the changes you need to make to your original servlet: parameter passing, session handling, styles (CSS).
At the same time there are a number of services that the portal provides you: user management, security, caching, etc.
Peter -
Hi,
I'm able to convert my simple servlets into portlets but I've a servlet which generates a lot of html code creates a frame also. I'm not getting any errors while running this portlet but it's not showing anything on the browser. Am I supposed to do anything else. Any help will be appreciated.
Thanks,
ChetanAccording to the Primer on Rendering Portlets,
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Some constructs cannot be used simply because they do not display correctly in a table cell. Frames, for example, do not appear when inserted in a table.<HR></BLOCKQUOTE>
Regards,
-rh
null -
i'm unable to include servlets in portlets.cud anyone suggest me how to go for it?
There are several ways of doing it. One such way is to use JSP
portlet with <jsp:include> tag in it.
Syntax: <jsp:include page="{relativeURL}" />
Use the following link to learn how to create portlets out of
existing java components
http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/pdk/articles/how.to.build.java.portlet.existing.component.html
If you are new to portlet development, please use the following
link to go to Table Of Contents page and decide where to head :
http://portalstudio.oracle.com/servlet/page?_pageid=350&_dad=ops&_schema=OPSTUDIO&12678_PDKHOME902_39847486.p_subid=249438&12678_PDKHOME902_39847486.p_sub_siteid=73&12678_PDKHOME902_39847486.p_edit=0
-AMJAD. -
Differences between Java Servlet and Portlets
Hello,
May anyone let me know the differences between Java Servlet, JavaBeans and Portlets? It seems quite similar to each other... By the way, what are differences between a servlet container and portlet container? Thank you.
CharoiteJavaBeans are totally different from servlets or portlets. JavaBeans can be used in just about any environment. A JavaBean is basically a java class with a no-arg constructor which follows certain naming conventions for its get and set methods.
Servlets can only function in an "web containers" which are provided by application servers which support servlets. The main function of servlets is to process requests (usually http requests) and generate output (usually web pages). They usually perform validation and other processing and then delegate the web page generation to a jsp.
Portlets are similar to servlets but rather than generating an entire web page, their output is relegated to a portion of a page. A single web page may contain the output of several portlets. These portlets can communicate with each other. The portlet container provides the functionality to merge the output of the various portlets and the infastructure required to support the portlets. -
How can we pass the control from servlet to portlet ?
Hi,
we use PortletRequestDispatcher.include method to call the servlet.
In my servlet, I have the following form information.
out.println("<form method=\"post\" action=\"http://abc 40acce5.3a.com/portal/dt?display=Command\">");
out.println("Enter value: ");
out.println("<input type=\"text\" name=\"UserName\" value=\"\">");
out.println("<center> "); out.println("<input type=\"submit\" value=\"Go Back Portlet\"> ");
out.println("</center> ");
out.println("</form>");
When user click the submit button, the servlet will go to portlet first, then go to another page.
is the url (action="http://abc40acce5.3a.com/portal/dt?display=Command) correct ?
if not, what url we should use ?
Can you help ?
Thanks!Oh I thought that you have selection-screen and again you are working on dialog programming.
if you want to use select-option directly in module pool then it is not possible.
but you can do other way.
create two varaiables
data : v_kun_low like kna1-kunnr,
v_kun_high like kna1-kunnr.
use these two variables in layout ,let user knows that he can not give options like gt,lt,eq ,it will be always BT.
and also when you see normal report program,you can use multiple values in either low or high,but here it is not possibel.
use can enter only low value and high value.
when you come to program point of view
declare one range
ranges r_kunnr for kna1-kunnr.
do the coding like
r_kunnr-low = v_kun_low.
r_kunnr-high = v_kun_high.
r_kunnr-options = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
now you can use r_kunnr in select query ,it will work like select-option.
other than this there is no option.
Thanks
Seshu -
Hi,
I have a servlet called Fileupdown.class that I have placed in the Apache/Jserv/servlets directory. When I call it from outside of Portals it works fine. I have made it into a Portlet by:
1) adding to the zone.properties file the following:
servlet.Fileupdown.code=oracle.portal.provider.v1.http.HttpProvider
servlet.Fileupdown.initArgs=provider_root=D:\providers\fileupdown, sessiontimeout=1800000, debuglevel=1.
2) creating the following provider.xml file and placing it in D:\providers\Fileupdown:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?providerDefinition version="2.0"?>
<!DOCTYPE provider [
<!ENTITY virtualRoot "/servlets/">
<!ENTITY physicalRoot "D:\Oracle\iSuites\Apache\Jserv\servlets">
]>
<provider class="oracle.portal.provider.v1.http.DefaultProvider">
<session>true</session>
<useOldStyleHeaders>false</useOldStyleHeaders>
<portlet class="oracle.portal.provider.v1.http.DefaultPortlet">
<id>1</id>
<name>Fileupdown</name>
<title>Fileupdown</title>
<description>Fileupdown Portlet</description>
<timeout>30</timeout>
<timeoutMessage>FileUpdown timed out</timeoutMessage>
<acceptContentType>text/html</acceptContentType>
<showEdit>false</showEdit>
<showEditToPublic>false</showEditToPublic>
<showEditDefault>false</showEditDefault>
<showPreview>false</showPreview>
<showDetails>false</showDetails>
<hasHelp>false</hasHelp>
<hasAbout>false</hasAbout>
<renderer class="oracle.portal.provider.v1.RenderManager">
<appPath>/servlets</appPath>
<appRoot>D:\Oracle\iSuites\Apache\Jserv\servlets</appRoot>
<contentType>text/html</contentType>
<charSet>UTF-8</charSet>
<renderContainer>true</renderContainer>
<renderCustomize>false</renderCustomize>
<showPage class="oracle.portal.provider.v1.http.Servlet20Renderer">
<servletClass>Fileupdown</servletClass>
</showPage>
</renderer>
<personalizationManager class="oracle.portal.provider.v1.FilePersonalizationManager" >
<dataClass>oracle.portal.provider.v1.NameValuePersonalizationObject</dataClass>
</personalizationManager>
</portlet>
</provider>
3) I registered the provider with Portal and place the portlet on a page. When I view the Portlet I am getting the providers test page appearing in the portlet.
What else do I need to do or what am I doing wrong?
Thanks for any help you can provide.
JAS
nullThere are a few differences between a servlet that runs on its own (in stand-alone mode), and a servlet that runs as a portlet.
Some of the changes you need to make to your original servlet: parameter passing, session handling, styles (CSS).
At the same time there are a number of services that the portal provides you: user management, security, caching, etc.
Peter -
Servlet to portlet. can see test page but not my servlet
Hello all.
-I'm trying to register a very basic servlet (it just write a message in get or post methods) named mpi_servlet.class
-I followed the instructions of "Packaging and Deploying Your Provider" and made the changes to the files.
-Copy mpi_servlet.class at <war working directory>\WEB-INF\classes.
-Write the following to <war working directory>\WEB-INF\providers\mpi\provider.xml.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?providerDefinition version="3.1"?>
<provider class="oracle.portal.provider.v2.DefaultProviderDefinition">
<session>false</session>
<useOldStyleHeaders>false</useOldStyleHeaders>
<portlet class="oracle.portal.provider.v2.DefaultPortletDefinition">
<id>1</id>
<name>MPI</name>
<title>MPI Portlet</title>
<description>MPI Portlet.</description>
<timeout>10000</timeout>
<timeoutMessage>MPI Portlet timed out</timeoutMessage>
<showEdit>false</showEdit>
<showEditDefault>false</showEditDefault>
<showPreview>false</showPreview>
<showDetails>false</showDetails>
<hasHelp>false</hasHelp>
<hasAbout>false</hasAbout>
<acceptContentType>text/html</acceptContentType>
<renderer class="oracle.portal.provider.v2.render.RenderManager">
<contentType>text/html</contentType>
<showPage>/mpi_servlet</showPage>
</renderer>
</portlet>
</provider>
-Write the following to <war working directory>\WEB-INF\deployment\mpi.properties
serviceClass=oracle.webdb.provider.v2.adapter.soapV1.ProviderAdapter
loaderClass=oracle.portal.provider.v2.http.DefaultProviderLoader
showTestPage=true
definition=providers/mpi/provider.xml
autoReload=true
-Zip and rename to mpi.war
-Copy mpi.war to <ear working directory>
-Write the following to <ear working directory>\META-INF\application.xml
<?xml version="1.0"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>Template Application</display-name>
<description>This is a template application</description>
<module>
<web>
<web-uri>mpi.war</web-uri>
<context-root>/mpi</context-root>
</web>
</module>
</application>
- Zip and rename to mpi.ear
-After deploy it at OEM Console and try "http://myhost:7777/mpi/providers/" I got the test page
Congratulations! You have successfully reached your Provider's Test Page.
Checking for components:
Portlets are:
MPI
Recognizing initialization parameters.
invalidation_caching : true
- The problem is that I cannot access my servlet at "http://myhost:7777/mpi/mpi_servlet/"Hi Marko,
You need to update the web.xml file in WEB-INF folder
Add the following lines to it,
<servlet>
<servlet-name>mpilogin</servlet-name>
<servlet-class>add the fully qualified class file name here</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mpilogin</servlet-name>
<url-pattern>/mpi_servlet</url-pattern>
</servlet-mapping>
- Abhinav -
Is it possible to use servlets with portlets?
I am building a Java portlet that will update a user's OID repository data. We are using it to provide a more user-friendly interface than the default Oracle "My Account" link on Portal.
That portlet is made up by a JSP that submits the information to a Servlet that, in turn, forwards it to another servlet (using RequestDispatcher) that does the actual OID update and then it should redirect the page flow back to the original JSP to show the user a confirmation message.
Things run fine up to where the OID entry is being updated correctly, but I am unable to redirect the flow back to the original JSP.
JSP ----> Servlet ----> Servlet
^------------------------------|
I did a little test and found out that after submitting the form to the 1st servlet, I cannot get a PortletRenderRequest object in that servlet.
I have read the available documentation about building portlets but I cannot get a clear picture as to how I am supposed to build a portlet that uses servlets, or if it is possible at all.
Is there a way to do this? Or if there isn't, can anyone provide an alternative?
Thank you in advance.
Best regards,
Aldo HerreraIf you mean the application AIM for Mac, it will depend on your download speed.
If you mean "Can I use iChat with an AIM a screen name and does it cost anything ?" then the answer is Yes you can and no it does not cost and there is no download to do.
If you mean "Can I use the AIM service with an @mac screen name and can this be done for free ? " then the answer is again yes.
A trail account cost nothing and will work in ichat after the 60 days is up
A Paid for but Lapsed account will also work in iChat and for this purpose can now be considered free.
As I said and hinted at before your first question does not make it clear what you are actually asking.
The Application AIM for Mac is stuck at version 4.7 and does not do Video or Audio Only chats.
It has things that are useful in tweaking Buddy Lists in iChat but it is not specifically needed to contact AIM Buddies.
9:00 PM Tuesday; June 24, 2008 -
Hello,
I installed JPDK, worked fine. Tried a few samples from JPDK on my page, worked fine. I created a subfolder called french under providers (actually a copy of "sample" directory). Copied my servlet and JavaWebService (a regular java class) to classes directory
Heres is my servlet
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class TranslationServlet extends HttpServlet
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException
super.init(config);
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String var0 = new String("");
try
var0 = request.getParameter("strEnglish");
catch(Exception e)
var0 = "";
e.printStackTrace();
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>TranslationServlet</title></head>");
out.println("<body bgcolor='#bdc6de'>");
out.println("<form name='frmInput' method='POST' action='TranslationServlet'>");
out.println("<input type='text' name='strEnglish' value=''>");
out.println("<input type='submit' name='btnSubmit' value='Translate'>");
out.println("</form>");
out.println("</body></html>");
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String var0 = new String("");
try
var0 = request.getParameter("strEnglish");
catch(Exception e)
var0 = "";
e.printStackTrace();
if(!var0.equals(""))
JavaWebService jws = new JavaWebService();
var0 = jws.convertEnglishToFrench(var0);
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>TranslationServlet</title></head>");
out.println("<body bgcolor='#bdc6de'>");
out.println("<p>" + var0 + "</p>");
out.println("</body></html>");
Here is my provider.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?providerDefinition version="3.1"?>
<provider class="oracle.portal.provider.v2.DefaultProviderDefinition">
<session>true</session>
<useOldStyleHeaders>false</useOldStyleHeaders>
<portlet class="oracle.portal.provider.v2.DefaultPortletDefinition">
<id>1800</id>
<name>FrenchServlet</name>
<title>English to French translation Servlet</title>
<shortTitle>French Servlet</shortTitle>
<description>This is the "hello world" sample implemented using Java Servlets and the extensible renderer architecture.</description>
<timeout>40</timeout>
<timeoutMessage>French Servlet timed out</timeoutMessage>
<hasHelp>false</hasHelp>
<hasAbout>false</hasAbout>
<showPreview>false</showPreview>
<showDetails>false</showDetails>
<showEdit>false</showEdit>
<showEditDefault>false</showEditDefault>
<acceptContentType>text/html</acceptContentType>
<renderer class="oracle.portal.provider.v2.render.RenderManager">
<contentType>text/html</contentType>
<autoRedirect>true</autoRedirect>
<showPage>/servlet/TranslationServlet</showPage>
</renderer>
</portlet>
</provider>
The provider registers properly with portal, but when I try to use the portlet i get "Internal server error, listener returned...."
Am I doing something wrong?
Please help...Hi Akshay,
Just a few concerns here,
1. Please check if you have made an entry in the web.xml file at %OC4J_HOME%/jpdk/jpdk/WEB-INF/ for TranslationServlet. Here i am assuming that your servlet code & provider.xml are inside the jpdk context path (i.e. inside %OC4J_HOME%/jpdk/jpdk folders)
A sample entry can be like,
<servlet>
<servlet-name>TranslationServlet</servlet-name>
<display-name>TranslationServlet</display-name>
<servlet-class>yourfullpackagestructre.TranslationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TranslationServlet</servlet-name>
<url-pattern>/servlet/TranslationServlet</url-pattern>
</servlet-mapping>
This will enable the servlet container to redirect all your requests to TranslationServlet.
2. I doubt if the following code extract will work,
out.println("<form name='frmInput' method='POST' action='TranslationServlet'>");
Here the action is to be taken by TranslationServlet, but you need to specify the complete URL for the TranslationServlet which might be something like
http://your OC4J host:port/servlet/TranslationServlet
You can generate this URL at runtime as follows,
String requestURL = request.getRequestURL().toString();
String requestURI = request.getRequestURI();
// "http://<host>:<port>
String baseURL = requestURL.substring(0, requestURL.indexOf(requestURI));
String completeURL = baseURL + "/servlet/TranslationServlet"
Put the completeURL in the action attribute of the form.
Hope this helps, let me know if it still doesn't work.
Regards,
Abhinav -
Passing parameters between portlets
Hi , I have a page with two portlets : one , done with the wizard , is a form , the other one is another form , but is done with a JSP.
My trouble is that with the second form , the one done with a JSP , I must insert into the database two values , one retrieved by the jsp itself , and the other one is a value of one field of the other form.
My question is how can I get , from my jsp , that value coming from the other portlet ???
Thanks
maxHi,
You can redirect to another page and pass parameters to it. For this, you need to know the pageid to which you have to redirect. Assign form action to
http://machine:port/servlet/page
PageServlet requires few other parameters (form fields) to redirect the control to the required page.
You can get them by making a call to
HttpPortletRendererUtil.htmlFormHiddenFields(pr,PortletRendererUtil.PAGE_LINK)
This returns a string similar to the following.
<INPUT TYPE="hidden" name="_pageid" value="54" />
<INPUT TYPE="hidden" name="_dad" value="portal30" />
<INPUT TYPE="hidden" name="_schema" value="PORTAL30" />
Parse it for _pageid and change the value to the page you want to redirect. Print these contents inside your form. Once you submit the form, it'll redirect the control to the page you want with the parameters.
--Sriram -
How do you reference image files in jsp which becomes a portlet ?
My portlet is a servlet managing jsp pages. In each of the jsp s, there are image files (*.gif) being referenced. I have placed the image files in .../public_html/WEB-INF/images/ in explorer. In my jsp, I am referencing the image file as
src="WEB-INF/images/help.gif"
On deploying my portlet, the image is not being picked up by the portal. Also, on moving the image and modifying the reference to it, I am still getting the same problem.
Can anyone advise, for my portlet to display the image correctly,
1) where should I place the image files ?
2) how should the jsp code reference it ?
Cheers,
TaraHi,
The behaviour you are reporting is an expected behaviour. If you want to include images in your JSP, you need to specify the complete absolute URL to the image on the midtier as only then can the portal invoke that image.
Actually, when you specified the relative URL
WEB-INF/images/help.gif, Oracle9iASPortal actually looks for the image help.gif in the directory structure WEB-INF/lib at its end. As no such file exists, the images are not rendered onto Oracle9iASPortal page.
So you got to use the following workaround,
Assuming your provider name is "temp" (deployed using temp.ear) & the image name is "help.gif" which is stored in the htdocs folder inside temp. This image is invoked by help.jsp
You can get the absolute path of this image as follows:
Request URL is : http://<host>:<port>/temp/providers/temp
Request URI is : /temp/providers/temp
So, Base URL = http://<host>:<port>
Servlet Path is : /temp/htdocs/help.jsp
Truncating the Servlet Path to /temp/htdocs & appending this to Base URL should give you
http://<host>:<port>/temp/htdocs
which is the directory that contains your image. add image name to this URL to get the absolute p[i]Long postings are being truncated to ~1 kB at this time. -
Passing parameter spage id and portal language to a report portlet
Hi,
how can I pass the page id and portal language to a report portlet so I can filter my query according to that page id and language. See the report query below:
select <information required> from ana_statistics
where portal_page = :page_parameter
and language = :portal_language
ThanksYes, you can.
Here is an example.
Form: on scott.emp table.
Define the On successful submission of a form as
go('http://<server>:<port>/servlet/page?_pageid=<page id>&_dad=<dad>&_schema=<schema>&dept='||p_session.get_value_as_NUMBER(
p_block_name => p_block_name,
p_attribute_name => 'A_DEPTNO',
p_index => 1));
Report: alos on scott.emp table:
select * from SCOTT.EMP where DEPTNO = :dept
and define the "before displaying the page" as
<portal schema>.wwv_name_value.replace_value(
l_arg_names,
l_arg_values,
p_reference_path||'.dept',
<portal schema>.wwv_standard_util.string_to_table2(nvl(get_value('dept'),10)));
Put those two portlets on a page, after you submit the form (after Insert, Update, Delete),
the page will be refreshed and the deptno will be passed to the report.
Hope this helps.
This example was built on portal 309. -
Connect refused in Exchange Portlet
Hi,
I am trying to config the exchange portlet using URL-services and basic authentication. When I get to create web provider, the following error show up:
An error occurred when attempting to call the providers register
function. (WWC-43134)
An unexpected error occurred: ORA-29532: Java call terminated by uncaught Java
exception: java.net.ConnectException: Connection refused (WWC-43000)
An unexpected error occurred: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java)
at java.net.Socket.<init>(Socket.java)
at java.net.Socket.<init>(Socket.java)
at HTTPClient.HTTPConnection$EstablishConnection.run(HTTPConnection.java:574)
(WWC-43000)
Any idea?
Thanks.Do you mean the IsItWorking page or the test.asp in exchange portlet?
They both work fine.
Thanks. I meant neither of these but the test page for provider. The
installation instructions document refers this in the file
"INSTALLING.MICROSOFT.EXCHANGE.55.PORTLETS.html" and under
"Configuring the Web Provider" section. You have to make sure
the provider's servlet alias
http://your_oracle_http_server_hostname:port/servlet/exchange55
is running fine before specifying this URL in the provider registration
screen.
Hope it is clear now :-)
Thanks,
Amjad.
Maybe you are looking for
-
Performance tuning in loop at itab statements
Hi , I have one internal table lets ITAB1[] , Its having 15,0000 Records. now I want to search only 5 records from ITAB1[] compairing ITAB2[] , ITAB2 having 15,0000 records. what is best method to search this records in minimum time. loop it ITAB1.
-
LabVIEW Openings in Bangalore, India
Captronic System Pvt. Ltd., a Select Alliance Partner of National Instruments, specializes in the design and development of custom automated test, control and acquisition systems for R&D, design validation and production testing. Captronic Systems is
-
I just got my new iphone 3gs yesterday and have not even had the time to have a nice look at it coz it just does not start. When I put the phone to charge the apple logo appears and after that just the sign of USB connector pointing towards itunes (w
-
ORA-12170:TNS connect timeout occured.
HI, i am getting this error when trying to connect, sqlplus, form builder in devsuite.10.1.0 can anyone help, plz........................ ORA-12170:TNS connect timeout occured. with regards, AJAZ.
-
hi experts i would like to know how to disable a pushbutton in dialog progr initially when the prog is executed. i have to show 2 push buttons on application tool bar, one of them is active and the other is not active . after execution when active bu