• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forwarding to a dynamic URL within a servlet...

 
Randal Cobb
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a "different" sort of request... I have a client that wants to publish a given URL but redirect to some other URL based on something in the existing URL. For example, a user may type in: http://some.server.com/someValue/some.page. But, what the servlet does is, reads the URL coming in and replaces a certain portion for some other value. Using the above, the URL would become http://some.server.com/codebasea/some.page (basically, replacing the 'someValue' with 'codebasea').

I've tried forwarding, but, the server (WebSphere 5.1) keeps doing a Java core dump as soon as I try to forward... I have code like this:
request.setAttribute("someattribute", someValue);
String forwardPage = new String("/" + calcCodebase(<someValue> ); <-- this generates the new URL replacing the necessary values as needed
request.getRequestDispatcher(forwardPage).forward(request, response);

Any suggestions on how else this might be accomplished?

Thanks in advance!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions on how else this might be accomplished?


Why would you want to find out another means to do it before finding out why this means doesn't work?

There are two essentail pieces of info you have left out of your report:

1) What is the URL to which you are forwarding?

2) What is the error dump?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic