0

I am getting a problem while passing query string values in String Array. The statements are as following.

words[0]=request.getParameter("word1");
words[1]=request.getParameter("word2");

The above statements gives me an exception and giving value 0. Please help me in this regard.

Thanks in advance.

6
  • 3
    Post the stack trace. Commented Apr 25, 2013 at 9:13
  • 3
    What exception ? Share the error stack trace. Commented Apr 25, 2013 at 9:13
  • 3
    Please also post the line in your code where you declare words Commented Apr 25, 2013 at 9:13
  • @PeterRader Did you read ServletRequest documentation carefully enough? Commented Apr 25, 2013 at 10:10
  • @skuntsel No. You are right. Commented Apr 25, 2013 at 10:15

1 Answer 1

3

Possible solutions/causes:

  1. Make sure your array is initialized: String[] words = new String[2].
  2. Make sure you have your input element inside form that is submitted.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.