if (asinInput.value == "") { alert('You must enter an Asin.'); return false; } else { <% DumperHelper dHelper = DumperHelper.getDumperHelper("MyCompany"); String asinInput = request.getParameter(ProductKeyReportServlet.ASIN_INPUT_FIELD); String[] lines = asinInput.split("\n"); for(int i = 0; i < lines.length; i++) { String[] lines2 = lines[i].split("\r"); for(int j = 0; j < lines2.length; j++) { String[] asins = lines2[i].split(","); for(int k = 0; k < asins.length; k++){ if(!dHelper.doesAsinExist(asins[i].trim(), "1")) { %>alert('One or more of the asins entered are not valid'); return false <% } } } } %>
What you see there is a some jsp code in the body of a javascript else satement. What I'm trying to do is get the the user entered text and parse it to see if the input is valid. Two questions: Can I do this? I've come to understand that the jsp code is the first to get rendered so if that is true it sounds like I cant. Secondly, What is the proper way to get javascript variables and set them to strings in jsp.