This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

kindly help me in redirecting....... as soon as possible

 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir,
i'm using tomcat and in tomcat my servlets files are on this path as
TOMCAT/WEBAPPS/Eagle/Web-inf/classes
sir now i have a very little problem that how i redirect on servlet page from a servlet page..
response.sendRedirect("/servlet/Title");
this is not working sir..
lets have a look on actuall file
[code]
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Login extends HttpServlet
{
Connection con;Statement stmt;ResultSet rs;HttpSession session;
public void init()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con= DriverManager.getConnection
"jdbc dbc:forum","sa","aptech");
}
catch(Exception e)
{
System.out.println("Error DSN");
}

}

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
String user_name=req.getParameter("name");
String pass_word=req.getParameter("pw");

res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><body>");
try
{
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select password, userid from biodata where userid='"+user_name+"'AND PASsWORD='"+pass_word+"'") ;

if(rs.next())
{
String login= rs.getString("userid");
session=req.getSession(true);
session.putValue("login",login);
out.println("helloo");
res.sendRedirect("servlet/title");

}

else
{
res.sendRedirect("http://localhost:8080/Eagle/pwWrong.html");
}

}
catch(Exception e)
{
e.printStackTrace();
}
out.println("</body></html>");

}
}
 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i am not mistaken while doing a redirect u need to specify the absolute path like u have done in the decond redirect and not the relative path.
Relative path is given in case of forwatd.
 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sir i'm confuse about its path
respone.sendRedirect("Over HERe");
Now here how can i set its path. if i'm writing as ("/servlet/servlet_name")
then in browser it show path like this http://localhost:8080/Eagle/servlet/servlet/servlet_name
etc
kindly help us in its path setting..
waiting for ur reply
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now here how can i set its path. if i'm writing as ("/servlet/servlet_name")

Oh no - not the dreaded "invoker" again. Your use of "/servlet/servlet_name" means that it:
1. Must have the invoker servlet turned on
2. If it does have the invoker turned on, it will look in the ROOT\WEB-INF\classes for a servlet_name.class
See this FAQ entry for a discussion of the invoker servlet.
Bill
 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohh thank u very muchh it is working nowww

thank u very muchh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic