Servlet Portlet

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

Similar Messages

  • Portal Release 1 (1.2.2.2) with servlet portlets Error

    Hi,
    Iam trying to get a servlet to work as portlet but I am getting the following error:
    Can anybody help me with this problem.
    [31/07/2003 13:29:38:484 CEST] sample/init
    [31/07/2003 13:29:41:171 CEST] vertis/Response status: 500 : java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest: method setAttribute(Ljava/lang/String;Ljava/lang/Object;)V not found
         at com.nl.vertis.pd.controller.PdController.doGet(PdController.java:56)
         at com.nl.vertis.pd.controller.PdController.doPost(PdController.java:68)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.portal.provider.v1.http.Servlet20Renderer.renderBody(Servlet20Renderer.java:155)
         at oracle.portal.provider.v1.RenderManager.render(RenderManager.java:165)
         at oracle.portal.provider.v1.http.ServletProviderResponse.showPortlet(ServletProviderResponse.java:524)
         at oracle.portal.provider.v1.http.HttpProvider.dispatchProviderAction(HttpProvider.java:660)
         at oracle.portal.provider.v1.http.HttpProvider.service(HttpProvider.java:390)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java, Compiled Code)
         at org.apache.jserv.JServConnection.run(JServConnection.java, Compiled Code)
         at java.lang.Thread.run(Thread.java, Compiled Code)Below is the provider config I use for this servlet-portlet
       <portlet class="oracle.portal.provider.v1.http.DefaultPortlet">
          <id>1</id>
          <name>LOIServletController</name>
          <title>LOI Servlet Controller</title>
          <description>LOI Servlet Controller description</description>
          <timeout>10</timeout>
          <timeoutMessage>LOI/PD controller timed out</timeoutMessage>
          <hasHelp>false</hasHelp>
          <hasAbout>false</hasAbout>
          <showDetails>false</showDetails>
          <showEdit>false</showEdit>
          <showEditDefault>false</showEditDefault>
          <acceptContentType>text/html</acceptContentType>
          <renderer class="oracle.portal.provider.v1.RenderManager">
             <appPath>&virtualRoot;</appPath>
             <appRoot>&physicalRoot;</appRoot>
             <contentType>text/html</contentType>
             <charSet>UTF-8</charSet>
             <renderContainer>true</renderContainer>
             <showPage class="oracle.portal.provider.v1.http.Servlet20Renderer">
                <servletClass>com.nl.vertis.pd.controller.PdController</servletClass>
             </showPage>
          </renderer>
          <personalizationManager class="oracle.portal.provider.v1.FilePersonalizationManager">
             <dataClass>oracle.portal.provider.v1.http.BaseCustomization</dataClass>
             <useHashing>true</useHashing>
          </personalizationManager>
       </portlet>

    Thanx,
    But how do I do that???
    Ive got the following servlet that functions as a controller. How do I recode it to work with jserv and pdk V2/1 or can u point me to some portal/servlet related examples?
    And then especially the get/setAttribute and dispatch functions.
    package com.nl.vertis.pd.controller;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.util.Map;
    import java.util.Set;
    import java.util.Iterator;
    import java.util.Enumeration;
    import java.util.Vector;
    import oracle.portal.provider.v1.*;
    import oracle.portal.provider.v1.http.*;
    import com.nl.vertis.util.GenericConfigObject;
    import com.nl.vertis.pd.data.*;
    import com.nl.vertis.blueprint.model.Constants;
    import com.vertis.util.log.*;
    import com.vertis.util.log.handler.*;
    public class PdController  extends HttpServlet implements Constants {
      private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
      private String _firstAction = "Search.do";
      private Config _cnf = null;
      private AppModuleLOIImpl _app = new AppModuleLOIImpl();
      private GenericConfigObject _obj = null;
      private BasicLog _logger = null;
      public void init(ServletConfig config) throws ServletException {
        try {
          if (config.getInitParameter("cFirstAction") != null) {
            _firstAction = config.getInitParameter("cFirstAction");
          if (_logger == null) {
            _logger = new BasicLog();
            _logger.addHandler(new FileHandler(LOG_PATH,LOG_FILENAME));
          // Even de configuratie inlezen.
          if (_cnf == null) {
            _cnf = new Config();
        } catch(Exception e) {
          e.printStackTrace();
        super.init(config);
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        _logger.activate();
        _logger.info("PdController","doGet","Starting..");
        GenericConfigObject _action = getActionObject(request);
        _logger.info("PdController","doGet","the action name = "+_action.getString("action"));
         request.setAttribute("actionObject",_action);
        _logger.info("We zijn voorbij een setAttribute gekomen");
        HttpSession _session = request.getSession();
        if (_session.getAttribute("appModule") == null) {
          _session.setAttribute("appModule",_app);
        RequestDispatcher dispatcher = request.getRequestDispatcher(_action.getString("action"));
        dispatcher.forward(request,response);
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
      private GenericConfigObject getActionObject(HttpServletRequest request) {
        String _objnName = null;
        if (request.getParameter("path") != null) {
          _logger.info("request.getParameter(\"path\") != null");
          _objnName = (_cnf.getGlobalForward(request.getParameter("path"))).getString("name");
          _logger.info("global forward 2 action name = "+_objnName);
        } else {
          _logger.info("request.getParameter(\"path\") == null");
          _logger.info("first action name = "+_firstAction);
          _objnName = (_cnf.getGlobalForward(_firstAction)).getString("name");
          _logger.info("global forward 2 action name = "+_objnName);
        return _cnf.getAction(_objnName);
    }

  • Programmatically Registering a JSP/Servlet Portlet

    ???Programmatically Registering a JSP/Servlet Portlet???
    OK, I have read all the literature on how to register a JSP/Servlet Portlet and have not seen any info on how to register a JSP/Servlet Portlet programmatically.
    I know for sure that you can register a PL/SQL Portlet programmatically via a couple of SQL and PL/SQL scripts that were given in the PL/SQL PDK examples.
    Bottom line, I want a way to register a new JSP/Servlet Portlet with ZERO GUI/User interface.
    My questions are:
    Is it possible to register a JSP/Servlet Portlet programmatically?????
    If it is possible to register a JSP/Servlet Portlet programmatically, were is the info on it or can you give me some examples of it????
    THANKS MUCH!!!
    null

    For a faster response, you may want to ask this question on the Portal Developer's Kit (PDK) Forum.

  • R separate personalization classes reqd 4  jsps managed by servlet portlet?

    My portlet is a servlet which manages multiple jsps. This servlet manages the session data as well as navigation between the pages. At the moment, I have separate personalization classes for each of the jsps. Each personalization class extends NameValuePersonalizationObject. The content on each of the jsps has to be managed within the portal.
    Do I need to have separate personalization classses or is it better to have one personalization class for all the jsps within my portlet ?
    Any help would be great, Thanks,
    Tara

    Hi,
    After going through your application scenario, i think you should use just one Personalization Class. A single class would suffice all the four JSPs.
    But, as you might be aware, a Preference Store can only store basic data types like String, boolean etc. Complex Data Types like Properties etc. cannot be stored directly using NameValuePersonalizationObject. If you are storing complex types, then you will have to extend this class & define methods to store & fetch data from this complex object into the Personalization Store.
    You might want to go through the following article which talks about Information Storage using Web Providers.
    http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/articles/overview.information.storage.html
    If there are any further issues, please get back.
    Regards,
    Abhinav

  • Need Help!  Applet Servlet Portlet Communication

    Hi
    My applet need to send a keyWord to let a portlet to do some operations. I know an applet can communicate with a servlet by URLConnection.But how can portlet? Can I consider a portlet as a servlet and let the applet communicate with the portlet like servlet by URLConnection? could you tell me whether this is possible?
    Thanks for your help.

    Hi
    You have a white-space in the codebase, remove it.
    If that doesn't help, make a static html page, test the Applet with it.
    /Tobias - hopes this helps

  • DifferenceS  BETWEEN Servlet & Portlet

    Hi
    Can anyone tell me the differences b/w portlet and servlet/jsp
    THanks
    belur

    �     Servlets can provide complete web pages, whereas portlets only provide fragments. These fragments are then aggregated to form a complete web page by the portal
    �     Portlets aren?t allowed to generated HTML code that contains tags such as base, body, frame, frameset, head, html, or title. The iframe tag can be used with caution.
    �     The user cannot access a portlet directly using a URL in the way that a servlet is accessed. Instead, the URL points to the page containing all of the portlets on one page
    �     Communication between the web client and the portlets is performed through the portal
    �     Portlets can be provided with buttons or controls to manipulate the portlets? window states or portlet modes
    �     Multiple instances of a single portlet can be placed onto the same page
    �     Portlets support persistent configuration and customization
    �     Portlets also support user profile information
    �     Portlets support two scopes within the session; application scope and portlet scope

  • Servlets (Portlets) fail to see session

    Hello,
    I have developed a suite of portlets in java. They use session level caching. I have them running perfectly on my development box. When I move them to production they fail to see session or page parameters. Anyone know why this is. I have tried every provider settting there is ( Always login,once per-session..).
    Thanks for your help in advance.
    null

    If you are running the provider and the portal on different instances of Apache, you can try making the servlet zones different on each instance. This worked for us.
    Also, check that your provider.xml is the same. There is a session tag in there as well as when you register the provider.
    Roger

  • Click on link in one portlet and open in another portlet

    how do you click on link in one portlet and open in another portlet?

    Hrmm... This is a IBM Question..
    Officially this is a meaningless buzzword promoted by IBM. Portals are some sort of Servlet but IBM incapable of explaining how they differ from ordinary Servlets. Some speculate they are used to present a webpage with many services on it such as a search engine, and news that come from diverse sources. The user is able to dynamically configure the contents and layout of the page much like Netscape home pages
    I don't understand what yhour asking..
    I am assuming you want to call another servlet (portlet)? That would be absurd to do .. You let the HTTP request and XML file to deal with the response of the portlet

  • IFS Access from Portal (Sample Portlets)?

    Just wondering if there are any sample JSP/Servlet Portlets floating around illustrating access to iFS (9.0.3 cmsdk) for document storage/management. Something that is a true portlet that lives properly within a portal environment would be ideal.
    thanks

    I was aware of the Oracle sample, but it really isn't that functional as indicated by other threads in this forum. It basically is a link to the iFS WebUI that jumps out of portal. In any case, we intend to work with the cmsdk which does not support WebUI.
    Can anyone share/point to some examples of portlets (JSP,Servlet based) that can access the facilities of cmsdk.
    thanks

  • Session-syncronized web portlets (a la master-detail), how to?

    Hi.
    Here is what I want: I have a number of servlet portlets on a page. The user activates a form action on one portlet. The parameters go to that portlet only. The portlet calls some data provider (e.g. a servlet) to fetch some data. When the data arrives the portlet makes it available to all portlet-threads (do i undersstand it correctly?) in the session and tell them to go and present the data according to their predefined XSLTs.
    Now my questions are: Is there built-in support for this syncronization in Portal? What should be the preferred way to do this? Or have I missed something in the docs? (In that case my appologies, but please point out for me.)
    FYI, our current solution is to have all portlets send requests with session info to a "conventional" servlet where the threads for slave portlets are put on hold and the master is passed on to the data layer. When the data comes back it is converted to XML. Then all threads in the session fetch the XML and send back to their respective portlets where the XSLT is done. Any comments on this solution?
    BTW, what is the best way to syncronize servlet threads based on session?
    Any information are much appreciated.
    Jian Hu

    One way of approaching your issue is to simplify. While portlets are executed in parallel, you are guaranteed that they will all be called at a point right after the page is requested and that they will all complete when the page is rendered (either by success or timeout).
    You cannot predict the order of execution between those two points in time, but you can use those bounds to your advantage.
    For example, if you can guarantee that you can commit information to a database before a new page request, you can have all your portlets read from that source.
    Synchronization is a tricky issue and there are others that may know more about it. I'm just presenting one possibility.

  • Building and Deploying Java Portlets

    I want to build a java portlet, the typical HelloworldApp.class. I've created the provider.xml file, the HelloWorldApp.class and I'm ready to deploy the provider. I follow the orders of the "How to build a Java Portlet" document. Then I go to the "Configuring OC4J" section where it says to refer tha article "Packaging and Deploying your provider". There, in the "Packaging your Provider" paragraph, says: 2. extract the template war file..." Where is that file?? Can anybody help. It's supposed to be an easy procedure. Isn't it? The same prosedure is followed to build a jsp portlet and a servlet portlet. Please help!!!
    Best Regards
    George Drepaniotis

    hi
    template.war file is in pdk.zip.
    it is in the template.ear file. when you extract template.ear file you can see that.
    i waste very much time to find it.i understand that
    oracle help documents are so complex and not clear.
    there are many products versions.and there is no organization to productbased documentation.
    if you know how to create .war and .ear file in windows200 please announce me.
    best regards

  • Linking to individual custom database portlets

    When we create menu items in Portal normally we can link to an individual form or report component created in oracle portal and exposed via url for show or other routine. We need to setup menu items each to link to our custom database portlets. Is there any API or any other way of invoking this programatically?
    For e.g. if I have a portlet helloworld_portlet can I invoke helloworld_portlet.show directly? Any examples would help.
    Also there are undocumented API's to link to tabs or to pages or via query of sbr views. Are there any documented API's to link to tabs or subtabs?

    Hi,
    I dont think what you want is possible, the whole idea of a portlet is that its part (building block) of a page and not being a webpage by itself.
    There are perhaps some workarounds
    - try displaying the portlet in detail modus
    - perhaps create a hybrid portlet, that is a servlet & portlet at the same time
    In one of my portlets im also linking to a portlet on another page. I keep the durable link of the page where the second portlet resides as a setting in my database

  • How to display image on Portlet ?

    Dear all,
    I am now designing an application using Oracle Portal to maintain a company's employee records.
    The application allows HR personnels to input employee information such as name, gender, age and so on. In additional, a photo of 250x300 will be uploaded to database as well.
    The application allows hr personnels to query the database for employees and the photos will be displayed on web.
    I will use JDeveloper for the development. I want to know how to display the photos on the web in Portlet?
    thanks
    George (HK)

    Well at the end of the line its still plain old html that is used to display images, to display an image in html (correct me if im wrong) the image has to be in the webfolder (or it can be a servlet that generates an image)
    You are getting the image from a database, so you need a servlet that gets this image and converts it to a format the html tag < img src="..." > understands.
    To be honest I never done this, but Im curious how you will do it.
    You could also try to use AJAX and load the image dynamically, you'll still need a servlet though. You must also understand that a portlet differs a little bit from a servlet, portlet need a portal to run, servlet can run on its own.
    Hope this helps, I hope you also get some other answers, let me know if you succeed, im curious

  • Powerpoint slides within a portlet

    Do you know how to scroll through a series of powerpoint slides every 5 seconds within a portlet that will work in both IE and Netscape?

    Hi Yeuker,
    A bit odd indeed ;)
    Ussualy its best to qualify your parameters inside a portlet, so if eg, you post your portlet twice on a page, your dealerNumber is unique for each portlet instance.
    In your code you do something like this
    String dealerNum = request.getQualifiedParameter("dealerNumber")and
    <input type="text" name="HttpPortletRendererUtil.portletParameter(pr, "dealerNumber")"/>If im not mistaken.
    On the other hand, if you dont quality your parameter, if you have 2 instances of the same portlet on your page, both will read the same dealerNumber value. I use this for some of my java pdk servlet portlets.
    I did have to add <passAllUrlParams>true</passAllUrlParams> to my provider though.
    Hope this helps.

  • Java Portlet - Passing control to object outside renderBody

    Is there a problem passing control outside renderBody in a Java Servlet portlet.
    I get an error using the below, the portlet just stops. Its fine when I put the code inside renderBody:
    public class ObtainMap extends BaseManagedRenderer {
    public void renderBody(PortletRenderRequest pr) throws PortletException {
    pProcessMapRequest pPMR = new pProcessMapRequest();
    //Pass in the portal renderer
    pPMR.pr = pr;
    //call the main function
    pPMR.pProcessRequest();
    class pProcessMapRequest extends Object{
    Thanks...
    etc

    Does the log say which class can not be found?
    How have you added the pProcessMapRequest class to the CLASSPATH?

Maybe you are looking for

  • Can't open pdfs with Adobe Acrobat X

    I can't open pdfs with Adobe Acrobat X. I get this message:   Warning: Distiller will not process .Log, .PDF or .JDF file extensions What do I need to do to be able to open .pdf files? I could open them previously.

  • How come I can't add lyrics to some music?

    For some reason I can't add lyrics to some music files.  The lyrics tab is gray'ed out.  What gives?

  • Currency Code

    I have a simple data form that has saved assumptions currency accounts, saved assumptions non - currency and some revenue currency accounts. I have unchecked Allow multiple currencies per entity and unchecked Show currency codes in the data form desi

  • Moved front row to trash and deleted in error.  How do I get front row back on?

    Front row was moved to trash and deleted trash in error.  How do I get front row back?

  • [Solved] No sound with ALSA (change default sound card)

    I installed Arch on another laptop and I am unable to get sound working. # lspci | grep -i audio 00:01.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Device 9840 00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD] FCH Azalia Controller (