• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsp forward tag

 
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String chgLocURL ="https://google.com";

<jsp:forward page="${chgLocURL}" />


its not working . Can somebody help how can i use string with jsp forward tag in my jsp.
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you declaring the String in a Java snippet or Javascript?

WP
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If chgLocURL is a scripting variable, then it's not visible to the EL. You should never be mixing scriptlets in with the EL. In fact, you should never be using scriptlets at all.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William P O'Sullivan wrote:Are you declaring the String in a Java snippet or Javascript?


As it's not valid JavaScript syntax, I think it's clear that it's a Java scriptlet.
 
Nitin Singla
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using below
<%

String chgLocURL ="https://google.com";

%>
<jsp:forward page= <%=chgLocURL%> />
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See my reply. Scriptlets are 10 years out of date. Read this JspFaq entry.

In any case, you cannot forward to a resource outside of the current web application.
 
Nitin Singla
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me out with this code fix:

my url is in strnig.
and i need to forward to this new url which is in my string, how should i forward. Please can somebody provide me with right code snippet?
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once again: you cannot forward to a resource outside of the current web app.

You'll need to redirect.
 
Nitin Singla
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the confusion. Actually the url is ini scope of my app only. google.com is just an example. Dont get confuse with this. Only thing i want to know if in anyway i can use this string so that i can forward to the url that is in the string.

Thanks
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nitin Singla wrote:Sorry for the confusion. Actually the url is ini scope of my app only. google.com is just an example.


This is called a "red herring" and is to be avoided. Show us real data, or as real as possible, and you won't waste the time of the people trying to help you. Please read AvoidRedHerrings.

Dont get confuse with this


Too late.

Only thing i want to know if in anyway i can use this string so that i can forward to the url that is in the string.


When you show us the real code, and show us the real errors that are occurring maybe we can help you.
 
Nitin Singla
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi .

Apologies for my previous reply.

Below is my code snippet:

<%
String chgLocURL ="/jsp/welcome.jsp";

%>
<jsp:forward page="{<%=chgLocURL %> }"/>


It is not working.
Please help me how can i use this string. I just need to forward to the path stored in string chgLocURL from my current jsp in my application.
Please help with the code snippet.
Once again apologies for my previous post.
Thanks.
 
Nitin Singla
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its giving page not found error.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the page exist? If so, where? Does it work when you hard-code the path into the directive? You're still very far from giving us complete information.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alternatively you can try using


difference between forward and redirect

http://javapapers.com/jsp/difference-between-forward-and-sendredirect/
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They do completely different things and are not interchangeable.
 
reply
    Bookmark Topic Watch Topic
  • New Topic