How to call any .tmpl file from servlet by sending some parameters ?
807580Dec 19 2009 — edited Dec 19 2009Hi,
I am new to Java Servlet and HTML template language ( anyfile.tmpl).
I have created simple login authentication with user registration for new user.
If user already exists, after successful login, he should be navigated to INBOX page (that inbox page is some inbox.tmpl file) from SERVLET itself using following BOLD statements given in code below. But its not working.. :-( Please do the needful.
Thank you.
if (session == null) {
try {
userName = request.getParameter("login");
pwd = request.getParameter("password");
if (!userName.equals("") && !pwd.equals("")) {
try {
//Database connection, data fetching, query execution etc.
// code will go here
while (rs.next()) {
if (userName.equals(rs.getString("username")) & pwd.equals(rs.getString("pwd"))) {
String u_name = userName;
String ph_no = (new Integer(rs.getInt("ph_no"))).toString();
String address = rs.getString("address");
session = request.getSession();
session.setAttribute("user", userName);
String inbox = context.getInitParameter(INBOX);
Template inboxTmpl = new Template(inbox);
* inboxTmpl.setParam("userName", u_name);*
* inboxTmpl.setParam("ph_no", ph_no);*
* inboxTmpl.setParam("address", address);*
* out.println(inboxTmpl.output());*
System.out.println("Login successful..");
break;
}
rs.close();
pstmt.close();
con.close();
(P.S - I am forced to use HTML.TEMPLATE(i.e. .tmpl file) instead of JSP)}