0

I have to support old URLs in my Play application and those used to pass parameters using # instead of ?, like mysite.com/?p#XXX instead of mysite.com/?p=XXX. The problem is that Play is ignoring everything that comes after the hashtag. No parameter is passed and when I check the URI of the request, I get only a substring that ends exactly before the hashtag:

request().uri()

gives only:

mysite.com/?p

Is there a way in Play to get the rest of the URL on the server side?

AHH
  • 902
  • 2
  • 9
  • 22
  • It's not really play that's your problem. It's that browsers do not send fragments (the part after the #) to servers ever. – EdgeCaseBerg Jul 12 '17 at 17:28

1 Answers1

1

This isn't a play problem. You'll encounter this with anything that's running in the browser because fragments are exclusively client side. W3 states:

In one of his XHTML pages, Dirk creates a hypertext link to an image that Nadia has published on the Web. He creates a hypertext link with "http://www.example.com/images/nadia#hat". Emma views Dirk's XHTML page in her Web browser and follows the link. The HTML implementation in her browser removes the fragment from the URI and requests the image "http://www.example.com/images/nadia". Nadia serves an SVG representation of the image (with Internet media type "image/svg+xml"). Emma's Web browser starts up an SVG implementation to view the image. It passes it the original URI including the fragment, "http://www.example.com/images/nadia#hat" to this implementation, causing a view of the hat to be displayed rather than the complete image.

Note that the HTML implementation in Emma's browser did not need to understand the syntax or semantics of the SVG fragment (nor does the SVG implementation have to understand HTML, WebCGM, RDF ... fragment syntax or semantics; it merely had to recognize the # delimiter from the URI syntax [URI] and remove the fragment when accessing the resource). This orthogonality (§5.1) is an important feature of Web architecture; it is what enabled Emma's browser to provide a useful service without requiring an upgrade.

(Emphasis mine)

I'm not sure what your old application was but it sounds like it was a javascript client side application. You'll have to have your front end real query parameters to play if your backend needs to do processing based on them.

Also, I think your question might be a duplicate of this one in a broad sense.

EdgeCaseBerg
  • 2,411
  • 1
  • 18
  • 37