Question: I am a beginner with a weak understanding of Java. I use Dr.Java and I get this error:

```
     "S cannot be resolved"

```

With this Java program:

```
import java.util.Scanner;

public class HDtest5

{
    public static int countWords(String str) {
        String words[] = str.split(" ");
        int count = words.length;
        return count;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter a sentence: ");
        String sentence = in.nextLine();
        System.out.print("Your sentence has " + countWords(sentence) + " words.");
    }

    {
        while (true) // have created infinite loop
        {

            if (s.equals("quit"))
            // if enterd value is "quit" than it comes out of loop

            {

                String[] words = s.split(" "); // get the individual words
                System.out.println("#words = " + words.length);
                for (int i = 0; i < words.length; i++)
                    System.out.println(s + "word[" + i + words[i] + " nchars = " + words[i].length());

            }
            System.out.println(s); // to Print string
            System.out.println(s.length()); // to print Entered string's length

        }
    }
}

```

What causes this error message? 
I thought all the strings called 's' should work together without any problems. Could you please help me to find out what is wrong with it? Thank you very much for any help, its much appreciated!

Ps. Just to be more clear, the purpose of my program is to output total number of characters, characters of each word and a number of words of the text entered in text window (scanner). The code should work perfectly, except this 's' string problem which makes the chunks of code not work together.

Answer: 
My code is in VB, in the view, create a helper function to load all URL query parameters into the form:

```
@Functions
Public Function GetRouteValues() As RouteValueDictionary
    Dim RouteValues As New RouteValueDictionary
    For Each Qstr As String In Request.QueryString
        RouteValues.Add(Qstr, Request.QueryString.GetValues(Qstr).FirstOrDefault)
    Next
    Return RouteValues
End Function
End Functions

```

then declare the form head as following

```
@Using (Html.BeginForm("MultipleHandler", "Files", GetRouteValues, FormMethod.Post))

```

This way, you passed your collection of query string to the action.

In the action, use the same function:

```
Private Function AllRouteVlaues() As RouteValueDictionary
        Dim RouteValues As New RouteValueDictionary
        For Each Qstr As String In Request.QueryString
            RouteValues.Add(Qstr, Request.QueryString.GetValues(Qstr).FirstOrDefault)
        Next
        Return RouteValues
    End Function

```

Usage:

```
Return RedirectToAction("Index", AllRouteVlaues)

```

Hope that helps :)
You need to include the query-string parameters in the new request "somehow".  

On way would be the following (this is also how MS does it with the `ReturnUrl` in their examples):

```
public ActionResult ChangePassword(ChangePasswordMessageId? message. int mobile = 0)
{
    // your code
    ViewBag.Mobile = mobile;
    return View();
}
[HttpPost]
public ActionResult ChangePassword(ChangePasswordViewModel model, int mobile = 0)
{
    // your code
    ViewBag.Mobile = mobile;
    return View(model);
}

```

and

```
@using (Html.BeginForm("ChangePassword", "Account", FormMethod.Post, 
    new { @class = "form-horizontal", role = "form", mobile = @ViewBag.Mobile }))

```