Results 1 to 2 of 2
- 02-22-2012, 02:32 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Where to put this source code ? *.java or *.jsp
Hi
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 <% %> ?
Java Code:import java.net.*; import java.io.*; { if (request.getMethod().equals("POST")) { 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())); reader.close(); } }
- 02-22-2012, 02:55 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Where to put this source code ? *.java or *.jsp
It's code.
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.
Similar Threads
-
I want the source code of DUK's Bank , the example code in Java EE 5 Tutorial 2010
By zahra in forum New To JavaReplies: 16Last Post: 01-31-2012, 08:36 PM -
How can I get a GUI preview on java source code
By KevinQ in forum AWT / SwingReplies: 2Last Post: 06-10-2011, 12:36 PM -
java compiler source code
By vkolluru in forum New To JavaReplies: 13Last Post: 02-24-2010, 07:28 AM -
Can we Obtain Java Source Code?
By tornado in forum New To JavaReplies: 7Last Post: 12-10-2008, 07:23 PM -
MavenJava - browse source code of all open source projects online
By jirkacelak in forum Java SoftwareReplies: 1Last Post: 11-28-2008, 06:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks