[jboss-user] [JBoss Seam] - seam remoting - can't get a string value

Chloe do-not-reply at jboss.com
Wed Oct 17 05:13:17 EDT 2007


Hi,
I use jboss-4.0.5.GA and jboss-seam-1.2.1.GA.
I use a remoting methode to verify a recaptcha code. 
I have to give IP address for getting this verification :
ReCaptchaResponse reCaptchaResponse = captcha.checkAnswer(IpAddress, challenge, response);
  | 
In order to get this IP address I use :
((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRemoteAddr()
But this code does not work in remote fonction because it use servlet !
That's why I decide to get this value at the begining of my conversation and set it in a string and after use this String in my remote function but the string value is null !
@Stateful
  | @Name("signUpManager")
  | public class SignUpManagerBean implements SignUpManagerLocal {
  | 	private String remoteAddress;
  | 	@Begin(join=true)
  | 	public void beginSignup(){
  | 		mb=new Mb();
  | 		remoteAddress = ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRemoteAddr();
  | 		System.out.println("IP:"+this.remoteAddress);
  | 	}
  | 	/**
  | 	 * Verification captcha
  | 	*/
  | 		@Begin(join=true)
  | 		public boolean verifyCaptcha(String challenge, String response){
  | 			System.out.println("IP:"+this.remoteAddress);
  | 			//Create an object recaptcha
  | 			ReCaptcha captcha = ReCaptchaFactory.newReCaptcha("6Ld8gwAAAAAAAOS89isUAzfokP4FnY4_EBWb3gjM", "6Ld8gwAAAAAAAEw7vRs4DXQ6qb5BlEG6VkrpH8F4", false);
  | 			//Check the answer of the user
  | 			ReCaptchaResponse reCaptchaResponse = captcha.checkAnswer(this.remoteAddress, challenge, response);
  | 			//if the answer is valid
  | 			if (reCaptchaResponse.isValid()) {
  | 	            return true;
  | 			}
  | 			else {
  | 	            System.out.println(reCaptchaResponse.getErrorMessage());
  | 	            return false;
  | 			}
  | 		}
  | }
The result of anonymous wrote : System.out.println("IP:"+this.remoteAddress); in the beginsignup function show me the good value of my IP address but when I call it from the remote function the String value is "Null" !

I add this code for more details :
@Local
  | public interface SignUpManagerLocal extends SignUpManager {
  | 	
  | 	@WebRemote
  | 	public boolean verifyCaptcha(String challenge, String response);
  | 	
  | 	public void destroy ();
  | 
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095946#4095946

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4095946



More information about the jboss-user mailing list