it is still not working.
is my jsp code write ? I not never jsp coding before.
Aaron Evans-2 wrote:
>
> Is your JSP under WEB-INF? In that case your jspView init param should
> have the value of /WEB-INF/jsp/view.jsp.
>
>
>
> On 12/1/06, hiren <[EMAIL PROTECTED]> wrote:
>>
>> I trying to use JSP in my portal code. But it is not working. Below is
>> my
>> code. If anyone can go through my code let me where I am going wrong.
>>
>> I not worked before with JSP and Portal.
>>
>>
>> DIRECTORY STRUCTURE:
>>
>> bookmark - WEB-INF - classes - BookmarkPortlet.class
>> - portlet.xml
>> web.xml
>>
>> jsp - view.jsp
>> edit.jsp
>>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>> BookmarkPortlet.java
>>
>>
>> import java.io.IOException;
>> import java.io.Writer;
>> import javax.portlet.*;
>> import javax.portlet.GenericPortlet;
>> import javax.portlet.PortletException;
>> import javax.portlet.PortletRequestDispatcher;
>> import javax.portlet.RenderRequest;
>> import javax.portlet.RenderResponse;
>>
>>
>>
>> public class BookmarkPortlet extends javax.portlet.GenericPortlet
>> {
>> public void doEdit(RenderRequest request,RenderResponse response)
>> throws PortletException, IOException
>> {
>> response.setContentType("text/html");
>> String jspName =
>> getPortletConfig().getInitParameter("jspEdit");
>>
>> PortletURL addUrl = response.createActionURL();
>> addUrl.setPortletMode(PortletMode.VIEW);
>> addUrl.setParameter("add","add");
>> request.setAttribute("addUrl",addUrl.toString());
>> PortletURL cancelUrl = response.createRenderURL();
>> cancelUrl.setPortletMode(PortletMode.VIEW);
>> request.setAttribute("cancelUrl",cancelUrl.toString());
>> PortletRequestDispatcher rd =
>>
>> getPortletContext().getRequestDispatcher(jspName);
>> rd.include(request,response);
>>
>> }
>>
>>
>> public void doView(javax.portlet.RenderRequest request,
>> javax.portlet.RenderResponse response)
>> throws javax.portlet.PortletException,
>> java.io.IOException
>> {
>> response.setContentType("text/html");
>> String jspName =
>> getPortletConfig().getInitParameter("jspView");
>>
>> PortletRequestDispatcher rd =
>>
>> getPortletContext().getRequestDispatcher(jspName);
>> rd.include(request,response);
>> }
>>
>>
>> public void processAction(ActionRequest actionrequest,
>> ActionResponse
>> actionresponse)
>> throws PortletException, IOException
>> {
>> String removeName = actionrequest.getParameter("remove");
>>
>> if(removeName != null)
>> {
>> PortletPreferences prefs =
>> actionrequest.getPreferences();
>> prefs.reset(removeName);
>> prefs.store();
>> }
>>
>> String add = actionrequest.getParameter("add");
>> if(add !=null)
>> {
>> PortletPreferences prefs =
>> actionrequest.getPreferences();
>>
>> prefs.setValue(actionrequest.getParameter("name"),
>> actionrequest.getParameter("value"));
>> prefs.store();
>> }
>>
>>
>> }
>> }
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>> view.jsp
>>
>>
>> <%@ page session="false" %>
>> <%@ page import="javax.portlet.*"%>
>> <%@ page import="java.util.*"%>
>> <%@ taglib uri='http://java.sun.com/portlet'
>> prefix='portlet' %>
>> <portlet:defineObjects/>
>> <%
>> ResourceBundle myText =
>> portletConfig.getResourceBundle(request.getLocale());
>> %>
>> <%=myText.getString("available_bookmarks")%><br>
>> <%
>> PortletPreferences prefs = renderRequest.getPreferences();
>>
>> Enumeration e = prefs.getNames();
>> if (!e.hasMoreElements())
>> {
>> %>
>> <%=myText.getString("no_bookmarks")%><BR>
>> <%
>> }
>>
>> while (e.hasMoreElements())
>> {
>> String name = (String)e.nextElement();
>> String value = prefs.getValue
>> (name,"<"+
>> myText.getString("undefined")+">");
>> %>
>> <%=value% ><%=name%> <BR>
>>
>> <%
>> }
>> %>
>>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>> edit.jsp
>>
>>
>>
>> <%@ page session="false" %>
>> <%@ page import="javax.portlet.*"%>
>> <%@ page import="java.util.*"%>
>> <%@ taglib uri='http://java.sun.com/portlet'
>> prefix='portlet' %>
>> <jsp:useBean id="addUrl" scope="request"
>> class="java.lang.String" />
>> <jsp:useBean id="cancelUrl" scope="request"
>> class="java.lang.String" />
>>
>> <portlet:defineObjects/>
>> <%
>> ResourceBundle myText = portletConfig.getResourceBundle
>> (request.getLocale());
>> %>
>> <%=myText.getString("available_bookmarks")%><br>
>>
>> <FORM ACTION="<%=addUrl%>" METHOD="POST">
>> <TABLE CELLPADDING=0 CELLSPACING=4>
>> <TR>
>> <TD>
>> <%=myText.getString("name")%>
>> </TD>
>> <TD>
>> <%=myText.getString("url")%>
>> </TD>
>> <TD>
>> </TD>
>> </TR>
>> <%
>> PortletPreferences prefs = renderRequest.getPreferences();
>>
>> Enumeration e = prefs.getNames();
>> while (e.hasMoreElements())
>> {
>> String name = (String)e.nextElement();
>> String value = prefs.getValue(name,
>> "<" +
>> myText.getString("undefined")
>> + ">");
>> %>
>> <TR>
>> <TD>
>> <%=name%>
>>
>> </TD>
>> <TD>
>> <%=value%>
>> </TD>
>> <TD>
>> <portlet:actionURL var="removeUrl">
>> <portlet:param name="remove" value="<%=name%>"/>
>> </portlet:actionURL>
>> "<%=removeUrl.toString()% ">
>> [<%=myText.getString("delete")%>]
>>
>> </TD>
>> </TR>
>> <%
>> }
>> %>
>> <TR>
>> <TD>
>> <INPUT NAME="name" TYPE="text">
>> </TD>
>> <TD>
>> <INPUT NAME="value" TYPE="text">
>> </TD>
>> <TD>
>> <INPUT NAME="add" TYPE="submit"
>> value="<%=myText.getString("add")%>">
>> </TD>
>> </TR>
>> </TABLE>
>>
>> </FORM>
>> <FORM ACTION="<%=cancelUrl%>" METHOD="POST">
>> <INPUT NAME="cancel" TYPE="submit"
>> VALUE="<%=myText.getString("cancel")%>">
>> </FORM>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>> portlet.xml
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <portlet-app id="bookmark" version="1.0">
>> <portlet id="Bookmark">
>> <portlet-name>Bookmark</portlet-name>
>> <display-name>Bookmark Portlet</display-name>
>> <portlet-class>BookmarkPortlet</portlet-class>
>> <init-param>
>> <name>jspView</name>
>> <value>/jsp/view.jsp</value>
>> </init-param>
>> <init-param>
>> <name>jspEdit</name>
>> <value>/jsp/edit.jsp</value>
>> </init-param>
>>
>>
>> <supports>
>> <mime-type>text/html</mime-type>
>> <portlet-mode>VIEW</portlet-mode>
>> <portlet-mode>EDIT</portlet-mode>
>> </supports>
>> <supported-locale>en</supported-locale>
>> <portlet-info>
>> <title>Bookmark</title>
>> <short-title>List of URLs</short-title>
>> </portlet-info>
>> </portlet>
>> </portlet-app>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>> web.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
>> 2.3//EN"
>> "http://java.sun.com/dtd/web-app_2_3.dtd">
>> <web-app>
>> <display-name>Bookmark Portlet</display-name>
>> <description>Bookmark Application for maintaining list of
>> URLs</description>
>> </web-app>
>>
>>
>> ---------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JSP-and-Jetspeed-tf2741960.html#a7650317
>> Sent from the Jetspeed - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/JSP-and-Jetspeed-tf2741960.html#a7653394
Sent from the Jetspeed - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]