I am trying to design .java pages in which i am fetching the data from database like simply i have a database and i am using servlet to fetch the data (.java file) which gives me the stored user's information but i am doing it by the help of out.println(""); so it just print the plane text/html but i need more design without using jsp or other framework if its possible. cause i don't have lots of knowledge about jsp and I am new to this Advance java.
public class profile extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
Connect connect = new Connect();
res.setContentType("text/html");
PrintWriter out = res.getWriter();
HttpSession session = req.getSession();
String fname = (String) session.getAttribute("name");
String lname = "", pass = "";
try {
Connection con = connect.getConnection();
PreparedStatement stmt = con.prepareStatement("select * from register where firstname = ?");
stmt.setString(1, fname);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
fname = (String)rs.getString(1);
lname = (String)rs.getString(2);
pass = (String)rs.getString(3);
}
// out.println("/index.html");
out.println("your profile :<br>");
out.println("your name is: " + fname + "<br>");
out.println("Your last name is: " + lname + "<br>");
out.println("Your Password is: " + pass + "<br>");
out.println("<a href='changePass.html'>Change password</a>");
out.println("<a href='delete'>delete user</a>");
} catch (Exception e) {
out.println(e);
}
}
}