well, I have used .htaccess with my sites in php .. but does it also work with JSP. becoz, JSP files will stay in tomcat/webapps directory and will run under port 8080.. I want to redirect in following way: http:<mysite.com>:8080/<app>/<filename.jsp>?id=1 to http:<othersite.com>/filename.html
You can use the sendRedirect(String) method on HttpServletResponse (the 'response' implicit object in a JSP) to redirect the client - this sends the HTTP "Temporary Redirect" header, and sets the "Location" (or equivalent) header to the URL passed as the argument to the method.
However, this method will throw an IllegalStateException if the response has been committed (which normally occurs when the response buffer is flushed for the first time). You therefore need to be extra diligant that nothing has been written to the client before invoking this method.
A better design would see this code inserted into a servlet rather than a JSP.
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )