Set Attribute in HttpServletRequest not working!!

asked 2013-01-07 09:37:09 +0800

biswajitdas gravatar image biswajitdas

I want to set some values in HttpServletRequest and pass it to another zul page. But it doesn't work. Though it works when i set attribute in session and get the value in zul file. I don't want to pass the value in query string as parameter.

Below are my zul file:


	<window apply="RequestParams">
		<textbox id="textBox1"></textbox>
		<button label="Submit" id="submit1"></button>


	import javax.servlet.http.HttpServletRequest; 
	HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
	String testValue = (String) request.getAttribute("test");
		<label value="${testValue }"></label>


public class RequestParams extends SelectorComposer {

	Textbox textBox1;
	@Listen("onClick = button#submit1")
	public void submitClick() throws IOException {
		System.out.println("In Submit " + textBox1.getText());
		//Executions.getCurrent().getSession().setAttribute("test", textBox1.getText());
		HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
		request.setAttribute("test", textBox1.getText());

Can any body please suggest what i'm doing wrong here? Or what is the correct approach to set some attributes in HttpServletRequest?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-01-07 19:19:46 +0800

gekkio gravatar image gekkio flag of Finland
899 1

Well, you are using a redirect which will cause the browser to make another request. Since its a different request than the first one, you cannot share any data with request attributes. The only choices are using the URL or the session.

link publish delete flag offensive edit

answered 2013-01-08 05:23:13 +0800

biswajitdas gravatar image biswajitdas

I got it.

Thanks gekkio!

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2013-01-07 09:37:09 +0800

Seen: 74 times

Last updated: Jan 08 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More