I am sending some data from AJAX to a servlet. This syntax works very well on my local.
xmlhttp.open("GET", "../MyTestServlet?section="+sId, true);
However, on our DEV UNIX server this does not work. I tried the following, but this does not work
xmlhttp.open("GET", "<%=request.getContextPath()%>/MyTestServlet?section=+sId", true);
The servlets are in the following package "com.myPackage.myApp.servlets"
What would be the right syntax?
Try using real path on the server system
ServletContext.getRealPath()
Well, the issue was not so much the path of the servlet, but a different one. Actually the Query.properties file also had path issues and once I solved it, it started to work. So actually the first link worked. Sorry folks for wasting your time on this one. Thanks for all the responses.
Related
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.
I'm trying to get a xml from a REST connection. In my local machine i receive it with the right encoding. e.g.: 수정완료 but in my server I receive the same request as ìˆ˜ì •ì™„ë£Œ.
Using the web browser in both machines I receive the REST request correctly.
Any ideas?
I'm using Apache Tomcat 6.0 in both machines
EDITED:
I'm follow this example:
http://support.openview.hp.com/selfsolve/document/KM997956/binary/ALM11.00_REST_API.html?searchIdentifier=-765a98c0%3a12de84ca170%3a-27ac&resultType=document
user: exampleStack
pass: example
Direct source link: http://h30499.www3.hp.com/hpeb/attachments/hpeb/itrc-895/68767/1/alm_rest.zip
Thanks in advance.
I finally got the answer to solve this issue thanks to this post: https://forums.adobe.com/message/3602618
What I needed to do was instead get directly the string from the Rest response, get its bite[] and then encode it correctly: =)
String myXmlEncoded = new String(con.httpGet().getResponseData(), "UTF-8");
Thanks guys.
I wrote a servlet on eclipse and when i tried to execute it the server gives me the below posted page.
To note: yesterday I executed the same servlet normally i could see the output, but when I tried to run it today i could not. I have not changed any thing every thing is the same.
The status code 404 means that the page is not be found, maybe you updated something in the web.xml file.
You should post contain of your web.xml file here, so that we can see the problem; or you can post the errors from log file if any.
Restart the server and try it.
If it doesnt work then try correcting the web.xml
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.
Is there a way to retrieve the absolute path of url (http://localhost:8080/myApp) in java. The scenario is, i need to connect to csv file located in tomcat server. The statement works well if I enter the absolute path, but is there a solution to retrieve url's path using getAbsolutePath().Sorry if I'm wrong.
Connection conn = DriverManager(getConnection("jdbc:relique:csv:/home/apache-tomcat-6.0.26/webapps/myApp/"))
Thanks in advance.
You can use ServletContext.getRealPath(), which does exactly what you want.
Note that it does not necessarily work in all situations. For example, if your Tomcat is configured to deploy the .war file without unpacking it, then this will return null.
I don't know much about JAVA.
May be getServletContext().getContextPath() is something you are looking for
EDIT:
Or may be getRealPath()
Tomcat is not a http server. All tomcat urls reference services, not files.
You'll have to implement another service that sends the csv file on request, if you want to get it through any http URL. URL's like http://localhost/myapp/input.csv require a http server like apache httpd.
(Hope I got your question correct...)