Object userObj = session.getAttribute("user"); Object passObj = session.getAttribute("password"); user = userObj == null ? null : String.valueOf(userObj); password = passObj == null ? null : String.valueOf(passObj);
String actualUser = getSessionAttribute(session, "user"); String actualPass = getSessionAttribute(session, "password"); user = actualUser == null ? null : String.valueOf(actualUser); password = actualPass == null ? null : String.valueOf(actualPass);
	public void generate() throws IOException, SAXException,			ProcessingException {		if (inputSource == null)			throw new ProcessingException("No input source");		Request request = ObjectModelHelper.getRequest(objectModel);		Response response = ObjectModelHelper.getResponse(objectModel);		Context context = ObjectModelHelper.getContext(objectModel);		Session session = request.getSession(createSession);				final String servletPath = request.getServletPath();		final String pathInfo = request.getPathInfo();		StringBuffer baseURIBuffer = new StringBuffer(servletPath);		if (pathInfo != null) baseURIBuffer.append(pathInfo);		int p = baseURIBuffer.lastIndexOf("/");		if (p > -1)  baseURIBuffer.delete(p,baseURIBuffer.length());            		final String baseURI = context.getRealPath(baseURIBuffer.toString());				String user = null;		String password = null;		// check if user and password can be read from the session		if (session != null && request.isRequestedSessionIdValid()) {		    Object userObj = session.getAttribute("user");		    Object passObj = session.getAttribute("password");			user = userObj == null ? null : String.valueOf(userObj);			password = passObj == null ? null : String.valueOf(passObj);		}		if (user == null)			user = defaultUser;		if (password == null)			password = defaultPassword;		try {			Collection collection = DatabaseManager.getCollection(					collectionURI, user, password);			if (collection == null) {				if (getLogger().isErrorEnabled())					getLogger().error(							"Collection " + collectionURI + " not found");				throw new ProcessingException("Collection " + collectionURI						+ " not found");			}			XQueryService service = (XQueryService) collection.getService(					"XQueryService", "1.0");			service.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");			service.setProperty(EXistOutputKeys.EXPAND_XINCLUDES,					expandXIncludes ? "yes" : "no");			service.setProperty("base-uri", baseURI);			service.setNamespace(RequestModule.PREFIX, RequestModule.NAMESPACE_URI);			service.setModuleLoadPath(baseURI);			if(!((CollectionImpl)collection).isRemoteCollection()) {				HttpServletRequest httpRequest = (HttpServletRequest) objectModel						.get(HttpEnvironment.HTTP_REQUEST_OBJECT);				service.declareVariable(RequestModule.PREFIX + ":request",						new CocoonRequestWrapper(request, httpRequest));				service.declareVariable(RequestModule.PREFIX + ":response",						new CocoonResponseWrapper(response));				if(session != null)					service.declareVariable(RequestModule.PREFIX + ":session",						new CocoonSessionWrapper(session));			}			declareParameters(service);						String uri = inputSource.getURI();			ResourceSet result = service.execute(new CocoonSource(inputSource, true));			XMLResource resource;			this.contentHandler.startDocument();			for (long i = 0; i < result.getSize(); i++) {				resource = (XMLResource) result.getResource(i);				resource.getContentAsSAX(this.contentHandler);			}			this.contentHandler.endDocument();		} catch (XMLDBException e) {			throw new ProcessingException("XMLDBException occurred: "					+ e.getMessage(), e);		}	}