dcsimg
301 redirect with jsp tag in redirect url
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Brandon_Smith
Posted On:   Sunday, September 25, 2005 08:39 AM

I'm trying to set a 301 redirect in my jsp code (this is tomcat btw) using this: <% response.setContentType("text/html"); response.setDateHeader("Expires", 0); response.setHeader("Location", "http://www.mysite.com/record/pleasehelpme /helpmeheretoo"); response.setStatus(301); %> the pleasehelpme and helpmeheretoo need to use variable values i get from mysql which i would normally express in the application like <%=(((Recordset1_data = Recordset1.getObject("avariable"))==null || Recordset1.wasNull())?"":Recordset1_data)%> so what do i need to stick in those parts of the path in the url? it works g   More>>

I'm trying to set a 301 redirect in my jsp code (this is tomcat btw) using this:

<%
response.setContentType("text/html");
response.setDateHeader("Expires", 0);
response.setHeader("Location", "http://www.mysite.com/record/pleasehelpme /helpmeheretoo");
response.setStatus(301);
%>

the pleasehelpme and helpmeheretoo need to use variable values i get from mysql which i would normally express in the application like

<%=(((Recordset1_data = Recordset1.getObject("avariable"))==null || Recordset1.wasNull())?"":Recordset1_data)%>

so what do i need to stick in those parts of the path in the url?
it works great redirecting to a flat url but I need those variable (well, that's the point of this anyway).
sticking the <%= recordset stuff %> is breaking since it's like a tag in a tag (i guess) - have tried variations on sticking println around (String)Recordset1.getObject("avariable") like
"http://www.mysite.com/record/(out.println(String)Recordset1.getObject("avariable"))"
and variations with curly braces and semicolons and everything but i keep getting
Syntax error on token "avalue", invalid AssignmentOperator
errors. (i'm obviously tring to figure out just one variable before i stick both in the path while i get this figured out).
can someone hit me with a clue stick?

   <<Less

Re: 301 redirect with jsp tag in redirect url

Posted By:   Christopher_Koenigsberg  
Posted On:   Sunday, September 25, 2005 11:36 AM

A jsp expression works usually where a tag-within-a-tag does not. So putting the dynamic stuff inside a jsp expression should work...



response.setHeader("Location", '<%= "http://www.mysite.com/record/" + myVar1Str %>');



where "String myVar1Str = (String)Recordset1.getObject(avar1)" has already been done previously, perhaps inside a helper bean.


About | Sitemap | Contact