As you see from the title, the problem is:
RewriteCond %{SERVLET_PATH} ^/(.+)
RewriteRule ^/(.+) /home.action [L]
-> then if I type domain.com/blahblah the home.action will be executed
However if:
RewriteCond %{SERVLET_PATH} ^/
RewriteRule ^/ /home.action [L]
-> then I type domain.com -> home.action never be executed!
I used an index.jsp (and declare in web.xml as well) and add:
response.sendRedirect("home.action");
DIDN'T work
Then add:
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=home.action">
DIDN'T work
As a result, I would be appreciated to hear your solutions in order to execute an action by only type the domain url without any path. Such as: domain.com
Thanks in advance.
It looks like you are using a root context. Therefore, would it be safe to say that you would normally access your action by going to http://www.domain.com/home.action?
If so, then you can configure HomeAction as the default action in your struts.xml.
Example
<action name="home" class="...">
...
</action>
<default-action-ref name="home"/>
Then, if you request just http://www.example.com/, it should invoke your home action.
Solved;
Don't write a condition, just only this ->
RewriteRule ^/index$ /home.action [L]
And your index.jsp should be:
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-9" />
<meta name="verify-v1" content="tonewfwefwewfwefwefrz4tqvroPwefewfy3izuwefwefKs=" />
<meta http-equiv="refresh" content="0;url=" />
</head>
<body>
<%
response.setStatus(301);
response.setHeader( "Location", "/" );
response.setHeader( "Connection", "close" );
%>
</body>
Related
I have the following HTML:
<html>
<head>
<meta http-equiv="refresh" content="0;URL=http://amazingjokes.com" />
</head>
</html>
I want to find the META with the redirect, so I wrote the following XPath query:
/html/head/meta[#http-equiv="refresh"]
However, the '-' in 'http-equiv' is causing an error:
Invalid regular expression: //html/head/meta[#http-equiv="refresh"]/:
Range out of order in character class
How can I properly rewrite the xpath query to be able to find the meta redirect?
I experimented with this, when I remove the '-' from the HTML code and the query things work as expected, but unfortunately the 'http-equiv' is a set standard, so I can not change that. This experiment showed me I am very close...
However, the '-' in 'http-equiv' is causing an error:
Invalid regular expression: //html/head/meta[#http-equiv="refresh"]/:
Range out of order in character class
Obviously, the XPath engine you are using is buggy.
The XPath expression used in the question is a valid XPath 1.0 expression and it selects the wanted <meta> element.
Here is an XSLT - based verification:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="/html/head/meta[#http-equiv='refresh']"/>
</xsl:template>
</xsl:stylesheet>
When the transformation above is applied on the provided XML document:
<html>
<head>
<meta http-equiv="refresh" content="0;URL=http://amazingjokes.com" />
</head>
</html>
the XPath expression is evaluated and the selected in this evaluation node is output:
<meta http-equiv="refresh" content="0;URL=http://amazingjokes.com"/>
I have a very simple JavaScript function that uses try/catch, though when the meta tag <meta charset="utf-8" /> is defined on the page, it doesn't work:
<!doctype html>
<meta charset="utf-8" />
<script type="text/javascript">
function demo(){
try{
undefinedfunction()
alert("I guess you do exist")
} catch(e){
alert("An error has occured: "+e.message)
}
}
</script>
<form method="post">
<b>Demo:</b> <input type="button" value="Click Me" onClick="demo()" />
</form>
In the above case instead of catching the undefinedfunction(), the console logs "Syntax Error: illegal character". If I remove the meta tag, the function behaves as expected, alerting a message.
Does anyone know why this is the case?
Ah nevermind, it seems the problem was with the spaces inside the function, instead of tabs. I guess "utf-8" is picky about those kinds of things.
I'm trying to display a table with some information and I have this code for that:
print $q->start_html(-title => "user summary");
print $q->table({-border=>1},
$q->tr($q->th(["Info","Value"])),#header
$q->tr($q->td(["Date",$date_var])),#first row
$q->tr($q->td(["Uptime",$uptime])),#second row
$q->tr($q->td(["1 min",$avg_one])),#third row
$q->tr($q->td(["5 min",$avg_two])),#fourth row
$q->tr($q->td(["15 min",$avg_two])),#fifth row
);
but when I run it I get:
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>user summary</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
Undefined subroutine CGI::tr
at ./index.cgi line 30
where ./index.cgi line 30 refer to this line print $q->table({-border=>1 and on the webpage I get 500 Internal Server Error
so any ideas?
I think it is
$q->Tr(...)
rather than
$q->tr(...)
tr is a synonym of y, the translation operator. Use Tr for CGI's table row.
You've got the right answer (twice) already, but I just wanted to point you at the "Non-Standard HTML Shortcuts" section of the CGI documentation, which says:
A few HTML tags don't follow the standard pattern for various reasons.
comment() generates an HTML comment (). Call it like
print comment('here is my comment');
Because of conflicts with built-in Perl functions, the following
functions begin with initial caps:
Select
Tr
Link
Delete
Accept
Sub
In addition, start_html(), end_html(), start_form(), end_form(),
start_multipart_form() and all the fill-out form tags are special. See
their respective sections.
In a JSP, do I need to provide a jsp:root directive and an XML namespace declaration. Or only the later. That is, if I have the following:
<jsp:directive.page language="java"
contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
/>
<jsp:root xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:s="http://www.springframework.org/tags"
/>
<!DOCTYPE html>
<html xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:s="http://www.springframework.org/tags">
<head>
... remainder of my HTML page
should I remove the jsp:root element? The information seems redundant. Removing the namespace declaration from the html element makes Eclipse complain.
You need the jsp:root element to set up the rest of the document to understand tags beginning with s: or c:. So don't remove it.
Is it possible to dynamically switch the title of a page that is served by Lift without having to write an extra snippet for that particular case?
One option is of course <lift:mySnippet><title>Default Title</title></lift:mySnippet> but I thought there might be an option along the lines of <head_merge><title>New Title</title></head_merge> (which inserts a second title node).
I do not like the first approach since I do not want to stick all the title generation logic into a single snippet and ask what kind of page I am on etc.
Have you tried to use templates?
You can define template in templates-hidden/default.html like this:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
<head>
<title>
<lift:bind name="title" />
</title>
...
</head>
<body>
<lift:bind name="content" />
</body>
</html>
And use it in index.html for example:
<lift:surround with="default">
<lift:bind-at name="title">Home</lift:bind-at>
<lift:bind-at name="content">
my content
</lift:bind-at>
</lift:surround>
You can find more information about templates here:
http://www.assembla.com/spaces/liftweb/wiki?id=liftweb&wiki_id=Templates_and_Binding
One way is to use the Menu.title snippet.
In bootstrap/liftweb/Boot.scala you define the sitemap with page names:
class Boot {
def boot {
// ...
def sitemap = SiteMap(
Menu.i("Home") / "index",
Menu.i("About") / "about")
// ...
}
}
In templates-hidden/default.html you use the snippet:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
<head>
...
<title class="lift:Menu.title">AppName:</title>
...
Then page titles will be: "AppName: Home" and "AppName: About". This is nice if you use
<span class="lift:Menu.builder"></span>
to build the menu, because page titles will be the same used in the menu.
Another approach is to use head merge and define the title in the page's html. For this to work, you have to remove the <title> tag from templates-hidden/default.html and put an <head> or <head_merge> tag in your content block:
<!DOCTYPE html>
<html>
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
<head_merge>
<title>TITLE OF THIS PAGE HERE</title>
</head_merge>
...