943,721 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 21959
  • JSP RSS
Sep 25th, 2005
0

Help with 301 redirect code - jsp in url

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bsmith is offline Offline
9 posts
since Sep 2005
Oct 3rd, 2005
0

Re: Help with 301 redirect code - jsp in url

Quote originally posted by bsmith ...
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?

You post is very confusing...but my guess is you need to do the following in your code...

JSP Syntax (Toggle Plain Text)
  1. // As long as there is a Recordset1 object by this time...
  2. <% String variable1 = (String)Recordset1.getObject("avariable") %>
  3. <% String variable2 = (String)Recordset2.getObject("avariable") %>
  4. <% String url = "http://www.mysite.com/record" + variable1 + "/" + variable2 %>
  5.  
  6. <%
  7. response.setContentType("text/html");
  8. response.setDateHeader("Expires", 0);
  9. response.setHeader("Location", url);
  10. response.setStatus(301);
  11. %>

Regards,

Nate
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: javascript variable in jsp session
Next Thread in JSP Forum Timeline: How do I pass data from a recordset on asp page towards an array on js file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC