Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes kindly help me in redirecting....... as soon as possible 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 » Servlets
Bookmark "kindly help me in redirecting....... as soon as possible" Watch "kindly help me in redirecting....... as soon as possible" New topic
Author

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

sandhiya sindhi
Ranch Hand

Joined: Sep 25, 2003
Posts: 50
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

Joined: Mar 11, 2004
Posts: 108
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

Joined: Sep 25, 2003
Posts: 50
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Sep 25, 2003
Posts: 50
ohh thank u very muchh it is working nowww

thank u very muchh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: kindly help me in redirecting....... as soon as possible
 
Similar Threads
Servlet Query
Servlet connection with Jdbc
validation problem using jsp,servlets,ms-access db
Connection reset by peer:JVM_recv in socket input stream read
problem with while loop when ResultSet.next() is called