Redirect to GSP failing - redirect

I'm using grails 2.4.5
In my grails-app/views directory I have a simple file called "test.gsp". Its contents are trivial GSP/HTML:
<html>
<head>
<meta name="layout" content="main" />
<title>TEST</title>
<style>
</style>
</head>
<body>
<h1>TEST</h1>
</body>
</html>
In a controller action, I have the line:
redirect(uri:"/test.gsp");
But whenever this line is reached, grails sends me off to the 404 handler.
I've tried enabling UrlMapping logging, and it shows:
DEBUG mapping.DefaultUrlMappingsHolder - Matched URI [/test.gsp] with pattern [/(*)/(*)?/(*)?(.(*))?], adding to posibilities
I was sure I had this working previously in Grails. What silly thing am I missing?

You should render a view and not trying to redirect to (probably not mapped) uri.
Try:
render(view: "test")

Related

Redirect github default homepage to my own page

i have recently create a github page but the default homepage is always this auto-generated homepage
But I directly want to go to my actual webpage,is there anyway to do it?
You can see an example of Using meta refresh to create an instant client-side redirect: there is no space.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The Tudors</title>
<meta http-equiv="refresh" content="0;URL='http://thetudors.example.com/'" />
</head>
<body>
<p>This page has moved to a <a href="http://thetudors.example.com/">
theTudors.example.com</a>.</p>
</body>
</html>
But in your case, your index.html does work on my side, and does redirect to default.html.

stackblitz -> because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

I have created a simple JavaScript project in Stackblitz and trying to include
dropzone.js but getting below error message
(index):1 Refused to execute script from 'https://js-gxqqqw.stackblitz.io/dropzone.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
There are lot of similar posts but I could not find anything that is relevant to stackblitz.
Here is my stackblitz link : https://stackblitz.com/edit/js-gxqqqw
In-fact I am not able to include any other JS file using script tag.
<script type="text/javascript" src="Not_able_to_include_any_js_file.js"></script>
Changing the script tag to link tag with rel="preload" and as="script" attributes should fix the issue.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Title of the document</title>
<link rel="preload" href="dropzone.js" as="script" />
</head>
<body>
Content of the document......
</body>
</html>
Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload#including_a_mime_type

anchor tag with href as other than http is not working while sending mail to gmail

I am using the smtp sendmail function, in the anchor <a> tag href attribute we have reference other than http:// ie something like below
transauth://some other data
but the gmail is not creating the hyperlink of transauth but creating of http://gmail.com ,Any solutions regarding this.
Gmail strips links that use custom uri schemas.
A work around however is that if you have a website somewhere you can host a simple redirect page that will redirect you to the correct schema.
This is a pretty bullet proof redirect here I copied from this answer to another question
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=http://example.com">
<script type="text/javascript">
window.location.href = "http://example.com"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow the <a href='http://example.com'>link to example</a>
</body>
</html>

Getting the address of embedded GWT application

I have a question regarding the embedding of a GWT application.
The problem concerns getting the address of the client, and match it to the ip in the tag's src attribute. So the structure is Host html page (hosted on server a), embedding a gwt application hosted on server b.
<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Embedding gwt app</title>
<script type="text/javascript" src="http://192.168.0.1:8080/myapp/myapp.nocache.js?rootpanel=divone"></script>
</head>
<body>
<div id="divone" style="width:100px;height:100px;"></div>
</body>
</html>
What we have tried before is get the host path by using GWT.getHostPageBaseURL(), but this returns the host page's ip (we expected this..)
Are we trying to achieve something impossible? considering that the script file gets downloaded first, and then the onModuleLoad gets called when the script is ready on the client.
You can make a RPC request to the server side, and the server can do the following to get the client's IP: getThreadLocalRequest().getRemoteAddr();
Or if you don't want to make a request and want to do the work on the client side, you can make a GWT native JS method and try one of the suggestions from this stackoverflow post: How to get client's IP address using javascript only?

301 redirect for site hosted at github?

Here's a Github repository of mine: https://github.com/n1k0/casperjs
There's a gh-pages branch to hold the project documentation, which is basically the project website: https://github.com/n1k0/casperjs/tree/gh-pages
This branch setups the documentation site at http://n1k0.github.com/casperjs/ — hurray.
In the meanwhile, I've bough the casperjs.org domain to get this website available through it, so I put a CNAME file as recommended in the docs: https://github.com/n1k0/casperjs/blob/gh-pages/CNAME — in their example, the operation is supposed to create redirects from www.example.com and charlie.github.com to example.com…
While the website now points to http://casperjs.org/, there's no 301 redirect from http://n1k0.github.com/casperjs/ (the old site url) to the new domain name.
Any idea how to setup such a redirect, if it's even possible? Is it a bug? If it is, where should I open an issue?
Bringing this topic back from the dead to mention that GH now supports redirect-from's redirect-to parameter https://github.com/jekyll/jekyll-redirect-from#redirect-to
Simply add this to your _config.yml
gems:
- jekyll-redirect-from
And this to the top of your index page.
---
redirect_to: "http://example.com"
---
To avoid the duplicate content, in a first time you can add a meta canonical like this:
<link rel="canonical" href="http://casperjs.org">
You can redirect using Javascript after host detection, like this:
if (window.location.href.indexOf('http://niko.github.com') === 0) {
window.location.href = 'http://casperjs.org{{ page.url }}';
}
But I agree, it's not an HTTP redirection.
Why didn't you use http://www.w3.org/TR/WCAG20-TECHS/H76.html?
That would give
<meta http-equiv="refresh" content="0;URL='http://casperjs.org/'" />
Github pages don't support anything like .htaccess or nginx/conf
https://help.github.com/articles/redirects-on-github-pages/
so easiest way is:
HTML redirect:
index.html
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://www.mywebsite.com/" />
</head>
<body>
<p>Redirect</p>
</body>
</html>
Manual layout method
If you don't feel like using https://github.com/jekyll/jekyll-redirect-from it's easy to implement it yourself:
a.md:
---
layout: 'redirect'
permalink: /a
redir_to: 'http://example.com'
sitemap: false
---
_layouts/redirect.html based on Redirect from an HTML page :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
{% comment %}
Don't use 'redirect_to' to avoid conflict
with the page redirection plugin: if that is defined
it takes over.
{% endcomment %}
<link rel="canonical" href="{{ page.redir_to }}"/>
<meta http-equiv="refresh" content="0;url={{ page.redir_to }}" />
</head>
<body>
<h1>Redirecting...</h1>
<a href="{{ page.redir_to }}">Click here if you are not redirected.<a>
<script>location='{{ page.redir_to }}'</script>
</body>
</html>
Now:
firefox localhost:4000/a
will redirect you to example.com.
Like this example, the redirect-from plugin does not generate 301s, only meta + JavaScript redirects.
We can verify what is going on with:
curl localhost:4000/a
Tested on GitHub pages v64, live demo at: https://github.com/cirosantilli/cirosantilli.github.io/tree/d783cc70a2e5c4d4dfdb1a36d518d5125071e236/r
No.
Other answers talk about redirections with meta refresh or javascript. But the OP asked about 301 redirects. And here's the answer: No. It is not possible. Your site on GitHub Pages is static, so you don't have any control over the server.
I had a similar issue when switching the domain for my github pages site. I set up rerouter on Heroku to handle the 301 redirects to the new domain. It handles domain-to-domain redirects very simply, but you may have to modify it to handle your site's legacy domain+path location.
I described the steps in detail here:
http://joey.aghion.com/simple-301-redirects/