This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Where to put this source code ? *.java or *.jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Where to put this source code ? *.java or *.jsp " Watch "Where to put this source code ? *.java or *.jsp " New topic
Author

Where to put this source code ? *.java or *.jsp

Boresm Borest
Greenhorn

Joined: Feb 22, 2012
Posts: 8
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 <% %> ?

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();

}
}
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
Java code belongs to java file. JSP falls under view in MVC(Model View Controller) architecture which is used to display the content. Business processing should done in java files.

<% %> using this you can include the same code in JSP file and make it work, but scriplets are not good practice and instead JSTL and EL should be used.

Hope this helps. and Welcome to Javaranch :)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

Yup, that's an easy one. No code ever goes into a JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where to put this source code ? *.java or *.jsp
 
Similar Threads
Internal Error while Validating username and password
jsp postgress connection
need help
HttpClient- username and password error.
user authentication servlet problem