| Author |
How to redirect to a new page using JSP?
|
Reeth Suresh A
Greenhorn
Joined: Aug 18, 2009
Posts: 5
|
|
Hi,
I will be generating a URL String in my java code.
1) I want this code to be accessed by a JSP
2) The JSP should redirect to a new page( new page is this URL from java code)
How should I write my JSP for this?
Thanks & Regards,
Reeth
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Reeth Suresh A wrote:
I will be generating a URL String in my java code.
2) The JSP should redirect to a new page( new page is this URL from java code)
Use servlet to redirect . are you using servlet in your module?
|
 |
Reeth Suresh A
Greenhorn
Joined: Aug 18, 2009
Posts: 5
|
|
|
No I am not using any servlet here. I am working on Documentum. This is just a simple java class. The URL string generated in the java class has to be used by the JSP to redirect
|
 |
samir singha
Greenhorn
Joined: Mar 17, 2008
Posts: 23
|
|
|
You can use jsp implicit object response's sendRedirect method. It will look like response.sendRedirect("url") or can use servlet's RequestDispatcher. Hope this will help
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Nop. you cant. sendRedirect is completely different . it makes new request,response object [client side]
|
 |
Reeth Suresh A
Greenhorn
Joined: Aug 18, 2009
Posts: 5
|
|
Is this possible
window.location="URl"..
But this URl is generated in my java code..how do I get this here?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Reeth Suresh A wrote:
window.location="URl"..
it is javascript
|
 |
Reeth Suresh A
Greenhorn
Joined: Aug 18, 2009
Posts: 5
|
|
|
yeah its a java script...
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Reeth Suresh A wrote:yeah its a java script...
then you need to pass the url value from jsp to javascript function
|
 |
Reeth Suresh A
Greenhorn
Joined: Aug 18, 2009
Posts: 5
|
|
eg:
THis is my java class:
Class A
{
method 1()
{
String url="....";
}
}
This is my JSP:
<%@ page import="A(my class)" %>
<head>
<script type="text/javascript">
window.location=request.getParameter(url);
</script>
Is this correct?
</head>
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
1.jsFunction('${url}')//preferred way
2.jsFunction('<%= request.getParameter("url") %>')
|
 |
Eduardo Bueno
Ranch Hand
Joined: Jun 04, 2009
Posts: 154
|
|
|
That will not work. If you want to pass a parameter from a java class to a JSP you must use a Servlet, otherwise you can use scriptlets inside your JSP (it is an option but don't do this).
|
 |
 |
|
|
subject: How to redirect to a new page using JSP?
|
|
|