Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>");

}
}
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohh thank u very muchh it is working nowww

thank u very muchh
reply
    Bookmark Topic Watch Topic
  • New Topic