Mochahost GWT rpc and Servlet not working - java

While deploying my app to mochahost, I met the problem between servlet and GWT-RPC communicate. The error shows:
HTTP Status 404 - /403.shtml
type Status report
message /403.shtml
description The requested resource (/403.shtml) is not available.
.war file works perfectly on my workstation, but not working on mochahost.
Any ideas to solve it?
Thanks in advance.

Mochahost have a very good support, try livechatting with their tech department, you will probably have the thing solved.
That's what I do.

Make sure you update live site URL. For instance, generally, on local system you access web app as http://localhost:8080/myapp but, on server it changes to http://[www.]myapp.com. Again, this is just an instance. The point is, the live site must reflect correct URL from code (servlet/JSP/action/etc...) and configuration properties, if any.
Comment 'DirectoryIndex' property in .htaccess file if you do not have any index file.
Comment 'RewriteCond' property in .htaccess file if you do not have any rewrite requirement.
For sure, one of the reason - if client does not accept cookies and servlet does not encode URL.

Related

Is there a way to convert all jsp files to static pages at once on server?

I have a website and now I want it to be able to work offline. I'm trying using service-worker to implement this function, but unfortunately, my website is written in multiple .jsp files. So when one jsp jumps to another jsp, the internet is required, as jsp is not able to be resolved in client browsers. Is there a way to solve this problem? Or do I need to rewrite all the jsp to one file?
Thanks in advance.
If your site is running on your own computer, configure it to accept requests on 127.0.0.1. Then you can use it when you are disconnected from the internet.
If the problem is that your JSPs link to each other via absolute URLs using your server's DNS name you could:
change the JSPs to use relative URLs, or
(hack!) temporarily tweak your DNS resolver to resolve the server DNS name to 127.0.0.1.
In general, it is not possible to convert a JSP to a static page, and still have it work properly.

Prerender.io not caching pages - followed all steps as per documentation

We are trying to use pretender.io to our application which developed in AngularJS, Spring and Hibernate konnectnow.com which hosted at amazon server.
Here are the steps I followed:
Signup at prerender.io and got token: cFeRZcsv3JnAftreuhMO
Checked documentation and understood that I need to install middleware and decided to use Spring one.
In web.xml added pom added as mentioned https://github.com/greengerong/prerender-java
Added !# to the URL in all the pages.
Restarted tomcat server.
Logged into pretender.io with login details and found that nothing getting crawl.
For testing purpose the url konnectnow.com/#!/planpage changed to konnectnow.com/?_escaped_fragment_=/planpage
Nothing comes up, got error page isn’t working.
Checked Crawl Stats at pretender.io and found that as:
Status Code: 505, Cache Hit: Miss, Response Time(sec): 1.51sec, URL:
http://localhost:8080/#!/planpage
Not sure why it takes local host.
Can some one help me how to make this work.
We recommend using html5 push state instead of the #! in your URLs if possible. Html5 push state is better since nothing after a # is sent to the server, which can lead to issues for the crawlers that are checked by their user agent (Facebook, Twitter, etc).
You should set the forwardedURLHeader in order to have the Prerender Java middleware use a different host for your website instead of your proxy URL.
https://github.com/greengerong/prerender-java#forwardedurlheader
I also see that you posted your prerender token publicly so we regenerated your token to prevent someone else from using it. Please find your new token when you log into your Prerender.io account. I've also emailed you there.

404 error when i call webservice in java

I have created a jersey web-service in Java and I have the following issue:
When I run the project in my localhost apache tomcat server, I call it with the URL localhost:8080/api/verify? and I haven't any problem.
When I upload it in my web-hosting and I call it with URL myDomainName/api/verify? I get 404 error.
Does anyone know why it's happened?
Thank you in advance
Check your web service to be deployed and successfully started (on 80 port).
Check your hosting security settings to allow access to /api/*.
Please try what others have suggested and also check if your domain name (myDomainName) is the correct one. If you have packed your projected as a war check the name of the generated folder.
Check your DNS server, your firewall, and your load balancer to make sure they are pointing to your app.
Verify if you are using http or https.
Edited to add: make sure your default tomcat port 8080 is there in the load balancer (if you have one). If you don't have one yet try http://yourDomainName:8080/api/verify and see if that's all you need.
Thank you all for your responses.
The problem was resolved by my web hosting support.
The solution was the following:
He changed the mappings (mod jk tomcat connector ) from .jsp to / to fix the issue.

response.sendRedirect to a file URL from Chrome

I have a URL shortener app (similar to tinyurl.com, bit.ly etc) which redirects to file:// URLs as well.
Internally, this is a Servlet based web-app, and all I do is, retrieve the targetURL and do a response.sendRedirect(targetURL) from the server side.
This works fine for file:// URLs too. However, recently, this has stopped working on Chrome. When I try to redirect to file://foo.txt (via a response.sendRedirect('file://foo.txt'), things simply fail (the Chrome debugger says "Cancelled").
Things work fine in FF and IE however. Any clues ?
I'd say this is a bad idea, and I'm glad at least chrome denies this (although I would suspect that other browsers would as well). It would be a pretty big security hole if you could instruct someone else's browser to open an arbitrary file.
Second, why would you want to do this? It would require that the user actually have this same file, at the same location on their computer. Seems like a pretty narrow use case. I tested your use case with bit.ly, and it you try to add a file:/// url there, it's regarded as an invalid URL and cannot be shortned.
Edit: There's a very good answer covering the same topic here. It references this useful resource about security restrictions with redirection.
You also specify that this is for an internal app. If you're attempting to do some sort of document sharing, I'd say you should look into dedicated systems for this. Another option is to extend your service with a "dropbox light", where your users can upload the file in question to a storage service, and you can generate a shortned url based on serving the file from your storage via regular http/https.

Error invoking servlet, but other resources get loaded - Flex + Java Application

I have written a RIA using flex for the front-end and Java servlet for the back end which actually makes calls to a web-service to do some processing.
The welcome page is a html page which is served from the web-logic 8.1 server that the app is hosted on. The welcome page loads and the flash content loads. Even a 'xml' file containing some configuration properties gets loaded from the server (through URL Request).
Now when I click a button on the page, it would authenticate the user, by sending the data to the servlet.
Here's the problem... The servlet doesn't get invoked and the URL Request (for the servlet with appropriate parameters) returns a 500: Internal Server Error page.
The same code is working perfectly when I deploy it on my local machine using tomcat as a server. And I have also checked umpteen times if the host URL is correct when being deployed on the web-logic server. Even checked the URL when the request is being made, in firefox, using firebug, and all seems to be fine, except that the response is '500: Internal Server Error'.
Please help. Thanks in Advance.
OK, the welcome page loads, and an XML file loads from the webserver, but the servlet can't be invoked.
Is the servlet initialising correctly, and waiting to be called?
Does anything need to be changed in the web.xml file that hasn't been?
Without any more information, it sounds like a misconfigured servlet and/or app server. Check your logs to see if there's any more information there.

Categories