1

I'm using the following piece of code for a Web Application

String OS=System.getProperty("os.name").toLowerCase();
if(OS.contains("win"))
{
    request.getRequestDispatcher("/result.jsp").forward(request, response); 
}

request.getRequestDispatcher("/result1.jsp").forward(request, response);

But when i run this application on windows OS it does not go to result.jsp.. It is going to result1.jsp

Am i using it in a right way?

barunsthakur
  • 1,196
  • 1
  • 7
  • 18

1 Answers1

0

OS prefix for windows returned by System.getProperty("os.name") is Windows so modify the if statement to something like if (OS.contains("Windows") or if (OS.startsWith("Windows"). Also put last statement in else block.

barunsthakur
  • 1,196
  • 1
  • 7
  • 18