Where to put this source code ? *.java or *.jsp
I am here not to get help about my source code content itself because it works but I am asking where to put this code ? in the *.java file or the jsp file ?
If *.java file then nothing easy then copy/past it into it but if it is jsp file so is it just put this code between <% %> ?
String userID = request.getParameter("username");
String userPWD = request.getParameter("password");
String data = "username=" + userID + "&password=" + userPWD;
String link = "http://website.com/script.php?" + data;
URL url = new URL(link);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
Re: Where to put this source code ? *.java or *.jsp
It doesn't belong in a JSP file.
Since it deals with specifics of a request then it should be in a servlet.
That servlet will then forward to a JSP after it's finished doing whatever it is it is doing.
Since servlets have doGet() and doPost() you can even skip the check on request method.