cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <>
Subject RE: Action problem
Date Sun, 18 Jan 2004 01:27:53 GMT
I don't see a serializer in your pipeline...

-----Original Message-----
From: beyaNet Consultancy
Sent: 1/17/2004 1:34 PM
Subject: Action problem

I have written an action which is meant to, for the meantime, return a
single column value. The problem is that you continually keep getting
redirected to the login page, which is meant to happen if a map is not
returned successfully. What am I missing? 

This action is called from a login page as so: 


<form action="testpage" method="post"? 

2. sitemap 

			<map:match pattern="testpage"> 
				<map:act type="get-detail2"> 
					<map:generate type="file"
src="content/main.xml" /> 
name="first_name" value="{first_name}" /> 
			<map:redirect-to uri="login.html" /> 

3. Action 

package test; 

import org.apache.avalon.excalibur.datasource.DataSourceComponent; 

import org.apache.avalon.framework.component.ComponentException; 
import org.apache.avalon.framework.component.ComponentManager; 
import org.apache.avalon.framework.component.ComponentSelector; 

import org.apache.avalon.framework.parameters.Parameters; 
import org.apache.avalon.framework.thread.ThreadSafe; 
import org.apache.avalon.framework.component.Composable; 
import org.apache.avalon.framework.activity.Disposable; 
import org.apache.cocoon.Constants; 
import org.apache.cocoon.environment.ObjectModelHelper; 
import org.apache.cocoon.environment.Redirector; 
import org.apache.cocoon.environment.Request; 
import org.apache.cocoon.environment.SourceResolver; 
import org.apache.cocoon.acting.AbstractAction; 

import java.sql.Connection; 
import java.sql.ResultSet; 
import java.sql.Statement; 
import java.sql.SQLException; 

import java.util.Enumeration; 
import java.util.HashMap; 
import java.util.Map; 

public class GetUserDetail2 extends AbstractAction implements
ThreadSafe, Composable, Disposable 
	protected ComponentSelector dbselector; 
	protected ComponentManager manager; 
	public void compose(ComponentManager manager) throws
		this.dbselector = (ComponentSelector) 
			manager.lookup(DataSourceComponent.ROLE +
	protected final DataSourceComponent getDataSource(String pool)
throws ComponentException 
		return (DataSourceComponent); 
	public Map act ( Redirector redirector, SourceResolver resolver,

					 Map objectModel, String source,
Parameters param) throws Exception 
		Request request =
		Map map = new HashMap(); 
		DataSourceComponent dataSource =
		Connection conn = null; 
			conn = dataSource.getConnection(); 
			Statement stmt = conn.createStatement(); 
			String cmd = "Select user_id, first_name,
last_name, address1, address2, address3, postcode, country, email,
home_telephone, mobile_telephone, date_joined from usertbl where
username = 'x' and userpassword = 'y'"; 
			ResultSet rs = stmt.executeQuery(cmd); 
			if ( 
				map.put("first_name", rs.getString(1)); 
		}catch (Exception e){ 
			getLogger().error("Query failed: ", e); 
				if (conn != null) conn.close(); 
			}catch (SQLException sqe) 
				getLogger().warn("Error closing the
datasource", sqe); 
		return (map); 
	public void dispose() 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message