Can you tell me Step-By-Step Guidelines of How to use HtmlUnit to make GWT app Crawlable? - gwt

Making your GWT app to be indexed by Search Engine is very important, but very very little info to tell you Step-By-Step Guidelines of How to make GWT app Crawlable dynamically.
Ok, Here is what I understood but I am not sure 100% I am correct or not. SO please correct me if you can.
To make a Gwt page ex myDomain.com#article;articleID=1 to be indexed by search engine, you need to:
-1st, convert myDomain.com#article;articleID=1 to myDomain.com#!article;articleID=1
-2nd, when Google /Yahoo bot visits that page (myDomain.com#!article;articleID=1), it will convert that page into (myDomain.com?_escaped_fragment_=article&articleID=1) & request that page into your webserver.The Web server then will try to render that page to the Bot.
So if we have a static page of myDomain.com?_escaped_fragment_=article&articleID=1, then the content of that page will be read by the Bot & can be indexed.
But the article is dynamic cos user could enter myDomain.com?_escaped_fragment_=article&articleID=2 or ...article=3... but we can't manually make the static page for each of article.
So the solution is HtmlUnit.
A tool like HtmlUnit will dynamically convert myDomain.com?_escaped_fragment_=article&articleID=2 into a page that the bot can read.
But I don't know step-by-step guidelines of How to set HtmlUnit up?
Is HtmlUnit like a jar file that we can put into lib? what should we do next?
used solution from Patrik, then compile then out int into webapp of Tomcat7 but got this err in the browser
type Exception report
message Filter execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Filter execution threw an exception
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)
com.gwtplatform.dispatch.server.AbstractHttpSessionSecurityCookieFilter.doFilter(AbstractHttpSessionSecurityCookieFilter.java:67)
com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
root cause
java.lang.NoClassDefFoundError: org/w3c/css/sac/ErrorHandler
myproject.server.CrawlFilter.doFilter(CrawlFilter.java:101)
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)
com.gwtplatform.dispatch.server.AbstractHttpSessionSecurityCookieFilter.doFilter(AbstractHttpSessionSecurityCookieFilter.java:67)
com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
root cause
java.lang.ClassNotFoundException: org.w3c.css.sac.ErrorHandler
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
myproject.server.CrawlFilter.doFilter(CrawlFilter.java:101)
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)
com.gwtplatform.dispatch.server.AbstractHttpSessionSecurityCookieFilter.doFilter(AbstractHttpSessionSecurityCookieFilter.java:67)
com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.53 logs.

See this SO working example inspired from this gwt-platform example and this Google documentation among others.
You setup HtmlUnit on the server side like any other library by adding their jar in you lib folder -- as far as I recall, that's all there is to it.

Related

Tuckey library for specific url pattern

I'm facing a problem.my company's website like http://localhost:8080/Product/Pages/Home.jsp
but when tried like http://localhost:8080/Product/Pa/ges/Home.jsp website tries to direct our 404 error page but not a proper way(comes a lot of errors and cant load the page) I guess It is about an apache tomcat bug ---> https://bz.apache.org/bugzilla/show_bug.cgi?id=61634
so, i am trying to implement tuckey library but I cant find a proper way to just let /Product/Pages/foo.jsp pattern.here is tuckey lib explanation --> http://tuckey.org/urlrewrite/manual/3.0/
I hope somebody can help me
I tried this rule and it redirect for old page.I am saying this, I can use this lib.But I cant figure out to which rule is proper for me.
/some/old/page.html
/very/new/page.html

Disabling SPA at porlet level

I have an WAR style application that has been converted from Liferay 6.2 to 7.1. it needs to have SPA turned off and has been tested successfully when turning off SPA at the portal level but would like to turn off at the portlet level.
have tried adding the false property to the object in liferay-portlet.xml but the app doesn't load into Liferay correctly after that and complains.
this appears to be the recommended approach from https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/automatic-single-page-applications. there may be some "order" necessary to these properties? I can't determine exactly what that might be from this DTD https://docs.liferay.com/ce/portal/7.1-latest/definitions/liferay-portlet-app_7_1_0.dtd.html#single-page-application.
a further inspection of the error message that occurs when the portlet is loading provides help that indicates the properties order that should appear in the liferay-portlet.xml. I'm able to deploy the portlet without error now.
unfortunately, the portlet still does not act properly. its an EXTJs front end and there are consistent "The schema can only be reconfigured once" and "duplicate object" errors reported in the browser console. reloading the entire page works fine.
how might one start to debug this issue?
I disabled SPA in a WAR application by setting <single-page-application> to false in liferay-portlet.xml
See: https://github.com/jorgediaz-lr/index-checker/blob/master/docroot/WEB-INF/liferay-portlet.xml#L18
<portlet>
<portlet-name>index_checker</portlet-name>
<icon>/icon.png</icon>
<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>
<control-panel-entry-category>
apps
</control-panel-entry-category>
<control-panel-entry-weight>1.5</control-panel-entry-weight>
<control-panel-entry-class>
jorgediazest.indexchecker.portlet.IndexCheckerControlPanelEntry
</control-panel-entry-class>
<preferences-company-wide>true</preferences-company-wide>
<preferences-unique-per-layout>false</preferences-unique-per-layout>
<single-page-application>false</single-page-application>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>index_checker-portlet</css-class-wrapper>
</portlet>
If that setting is not working to you and causes errors, please copy your log traces with the problems.

GWT servlets not called at all

I have ported GWT basic Hello World application to jetty-maven-plugin based app.
Everything goes fine, gwt convert client side classes to Javascript and application run properly in dev mode but no response for server side servlet. I do not get any error or exception.
Any idea what is going wrong.
Thanks
There is not much information to gave 100% answer. But be sure to check:
Server log output (could be some exception there)
If there are no exceptions on server side open console in Firebug or Google Dev Tools and load the page in browser. Probably there will be 404 not found errors.
Check if your servlet is correctly defined in : war->WEB-INF->web.xml.
Definition of servlet is:
I'm sorry but I can't put code example. I don't understand why.
Anna

Netbeans project integration with different frameworks

We work as a third party with MVC traditional framework with oracle 11g (no hibernate) with login.jsp page to enter the systems
The main company took the
struts2 and spring and hibernate frameworks approach also with oracle 11g and they have thier login.jsp
When we integrated our work together the login.jsp approved the is the last one due to privileges issues (from the main company) although they are too similar but its programmed with hibernate,struts,spring.
There is one problem occurred that their login.jsp page gives an error (below)
java.lang.IllegalArgumentException: Unknown entity: com.uts.entities.appsecurity.Users
The details is too long so i stored it in jsfiddle just for viewing...
The error
Now i should mention when integration i added some extra files .xml from the main company to work with theire framework in addition to their actual work:
1)libraries
2)persistence.xml
3)struts.xml
4)validators.xml
5)applicationContext.xml
Now if i enter the login.jsp i used to use in development it works but not the main company login.jsp we are looking for a solution for this !
the deploy does not give an error and when pressing login apachetomcat output does not give an error , it just redirect to error page on http://localhost:8084/HumanResources_2/presentation/securityAction.action
The main company login
http://localhost:8084/HumanResources_2/presentation/Login.jsp
Our(my) login
http://localhost:8084/HumanResources_2/login.jsp
Another thing the login page of the main company the text appearing as undefined all of them.
i don`t know what causing this it works before integration , note that the main company using Eclipse am ready for any thing i can provide
the problem was a BUG in netbeans
look at the photo there is line i must remove to make it work the selected one
the check when true the above line added automatically am not sure why but it solved it

GWT - spring security - caching issue

I have a GWT application which is secured by Spring Security. I have a Main.html which serves the application and Login.html for login. For most part everything works fine everytime. But sometimes after restarting my application I can still access Main.html - although most of the widgets on the page are unusable. I can see the Login.html's HTML in the console being printed as exception. On refreshing, it takes me to login page. Has anyone ran into similar issue? Is this some kind of caching issue? How can this be avoided?
It seems that in your case your bootstrap file is beining cached and thus a wrong version of your app is being loaded.
You have to make sure that your bootstrap file (the one which is named nocache) is never cached. See here for more details.
You can check if your bootstrap file is cached by using Firebug and looking at the HTTP requests for your scripts. You can check two things:
If the correct <md5>.cache.html are loaded (compare it to the ones in your gwt output folder).
The response type of your .nocache. file is not 304 or so.
Adding meta tag on top of my Main.html - helped me resolve my issue for now.
Read this for more details : HTML http-equiv Attribute