[opencms-dev] Re: forward command

bub habub japorami at yahoo.com
Thu Jun 30 11:10:48 CEST 2005


hi,

so i tried now so many things. and came to the
conclusion that i somehow don't get the parameters
that i try to get from the first page. 

i think the response.sendRedirect("mail.jsp"); 

works but then the next page cannot get the parameters
from this former page and therefore throws a
java.lang.NullPointerException


why can't i get the variabls values that i have
declared in in the former page?

here my code, maybe someone finds any mistakes:

first page that should check on the files

<%@page import="org.opencms.file.*,
org.opencms.file.collectors.*, java.util.*,
org.opencms.jsp.*, org.opencms.flex.*,
org.opencms.util.CmsUUID" %>
<%@ taglib prefix="cms"
uri="http://www.opencms.org/taglib/cms" %>
<%
CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);
//CmsDefaultResourceCollector collector = new
CmsDefaultResourceCollector();
String folder = "www/";
out.println("Current folder=" + folder);

CmsObject cmsobject =
CmsFlexController.getCmsObject(request);
List listfiles =
cmsobject.getResourcesInFolder(folder,
CmsResourceFilter.DEFAULT_FILES);

Iterator iterator = listfiles.iterator();
out.println("Items in this folder: list:");
long lastdate, time;
Date today = new Date();


while (iterator.hasNext())
{
    	CmsFile temp = (CmsFile)iterator.next();
	//out.println(temp);
	lastdate = temp.getDateLastModified();
	//out.println(date);
	
	time = today.getTime();
	//out.println(time);
	if(time-lastdate > 111840950)
	{
		
		CmsUUID userid = temp.getUserLastModified();
		CmsUser projectleader = cmsobject.readUser(userid);
		
		//out.println(userid);
		String emailofuser = projectleader.getEmail();
		String lastname = projectleader.getLastname();
		out.println(emailofuser);
		
		String url = temp.getRootPath();
		String filename = temp.getName();
		//out.println(url);
		out.println(filename);				//muss noch genauer
aufgebaut werden
		String forwardUri = "send_update_note.jsp";
 
		//response.sendRedirect(cms.link(forwardUri));
		response.sendRedirect("send_update_note.jsp");
		}
}

%>


second page that is supposed to send an email when a
certain time period has run down.

<%@ page import="org.opencms.mail.*, java.io.*,
java.util.*, org.opencms.jsp.*" %>
<%@ taglib prefix="cms"
uri="http://www.opencms.org/taglib/cms" %>
<%
CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);

String email = request.getParameter("emailofuser");
String lname = request.getParameter("lastname");

CmsHtmlMail amail = new CmsHtmlMail();

// Set To
out.println(email);
out.println(lname);
amail.addTo(email);


//Set From

String from = new String("onkel puenktlich" );

amail.setFrom("japorami at yahoo.com", lname);

// Set Subject

amail.setSubject("Please update project"); // better
with a variable for multiple use

// Set Headers

//amail.setHeaders(ht);


// Set Host
amail.setHostName("ipaddress");


// Details for Authentication

amail.setAuthentication("something");

String htmlcontent = cms.getContent("test2.html");
out.println(htmlcontent);

amail.setHtmlMsg(htmlcontent);

// Sending the Email
amail.send();

%> 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the opencms-dev mailing list