Run a file locally in java (reach with 'localhost') - java

I've been requested at work to run a file (server app) locally (so I will have it in localhost) and then send http get requests as I desire.
(I'm using get requests in the form "wget ..... http://localhost:4567/XXXX"
XXXX contains the name of the item I'm trying to receive.
I'm not familiar with the term 'run a file locally'. Can anyone explain / direct me to a website that explains about it?
Suppose my server file name is 'server'. How do I run the file (locally) in java? (so I'll be able to send HTTP get requests as I've mentioned above)

Are you asking for running html files locally so that they can be accessed through a port? If this is the case you need to have a http server on your desktop/laptop and configure it to enable your html files. If it is complete J2EE/.Net/any other platform applications, we need to install appropriate web/application server and run the same.

You have to create webservices and define its path. Suppose if you create a method give it a #Path('someName'). Define what it should consume and what it should produce using #Consumes(MEDIA_TYPE.xxx) #Produces(MEDIA_TYPE.xxx). The whole project will have a base path like restApi. Run it using apache tomcat i desired port. Access the rest api with the url http://localhost:8080/restApi/someName. Refer java webservices for more details. Its very simple. Starting configuration may take some time. So start with a maven artifact for java webservises to have a head start.

If you only want to send some GET requests to check the responses I would use a simple REST client like Postman. Just enter your URL, choose the GET method and send the request.
To run something locally means that the server is installed locally. You would deploy your file/s (.war or .ear in the case of java) to this local server. After that you can access the deployed services via http://localhost:port/...

Related

Convert java project to apache-tomcat hosted project

I created an application that is running locally without server. It recieves data through a socket, processes it and then sends the result back.
I want to host it on a local apache-tomcat server using Eclipse, and I already created the server.
How can I run the program on the server ? Do I have to convert the project to a web project ?
Couldn't find any tutorial except for webpage-creating projects...
Thanks
If you're already using sockets, there is a good chance Tomcat won't be serving your needs. As for web application projects, you need to use, e.g. Servlets to serve requests on server wrappers like Tomcat.

Apache Jmeter Recording Controller Uploading file

I'm using Apache Jmeter recording controller utility to access a certain website...when using website normally without jmeter proxy settings and other stuff, website works fine with full functionality....but when using Jmeter proxy settings I'm not able any more to upload to the website and it displays me an error.
any ideas!
If you are testing from behind a firewall/proxy server, you may need to provide JMeter with the firewall/proxy server hostname and port number. To do so, run the jmeter[.bat] file from a command line.
How to run the .bat file and how to change its parameters can be find in given URL:-
http://jmeter.apache.org/usermanual/get-started.html#proxy_server
I am sure that should work.

Server to Server communication with IBM SBT

I would like to use the IBM SBT for server to server communication instead of displaying data from , for instance, connections at the user. In this particular usecase I would like to have data updated in Connections whenever a user saves or edits data.
Because we are not using oAuth we would like to use Basic authentication without prompting the user for authentication. Are there any examples how to do is?
yes there are some examples of using Pure Java, no J2EE.
http://bastide.org/2014/01/28/how-to-develop-a-simple-java-integration-with-the-ibm-social-business-toolkit-sdk/
and
https://github.com/OpenNTF/SocialSDK/blob/master/samples/java/sbt.sample.app/src/com/ibm/sbt/sample/app/BlogServiceApp.java
Essentially, you'll need the dependent jar files.
once, you have the jar files you need to configure your class so you can get an Endpoint
once you have the endpoint you can use the endpoint in one of the top level services such
as ForumsService
then you can use the ForumsService to call back to Connections

How to call a web service inside another webservice

I need to consume a secure webservice deployed in WSO2 AS from another web service develop in axis2 and deployed in apache tomcat.
I create a java project to test the secure webservice client and I work OK.
But when I move the client code inside the axis2 service I cannot access to some resources like in this cases:
System.setProperty("javax.net.ssl.trustStore", "keys\\store.jks");
in this case I have the keys folder in the root of the wb services
sc.engageModule("rampart");
and in this case I leave the code idem
Any idea about this?
Well getting a resource path from an archieve file whether it is a jar ,war or aar is a tedious problem. There are two options two choose from:
1- Since client application runs on a servers put jks file somewhere on the server path, its path retrieved dynamically via property. (Either system property, servers context etc.)
2- A customSSLFactory handling loading keystore from resources.
This SO thread mentions such solution, which i used it too to connect to server via SSL from a web service without touching system properties.

Downloading files from remote server Java

I am looking for suggestions on implementing this requirement:
The requirement is for users on a public website to be able to download files of any kind.
The webserver for the website resides on a DMZ, the server that stores the files is internal to our corporate network. The webserver would have to communicate with the file storage server to get the files. What would be the best way to implement this?
Map that file server as a network drive in the disk file system of the web server and then add another web application context to the servletcontainer configuration which references the network mapped path.
It's unclear what servletcontainer and platform you're running/targeting, so I can't give a more detailed answer. But if it were Tomcat, then it's a matter of adding the following <Context> element to Tomcat's /conf/server.xml, assuming that you've mapped the file server on /path/to/mount/share:
<Context path="/share" docBase="/path/to/mount/share" />
This way it's available by http://localhost:8080/share/
It looks like that you want a proxy-like component to serve backend files... Personally I wouldn't use an application server for such a task, instead use simply a webserver. Some options:
Network share: Create a network share just as BalusC proposed and configure your web server to use that share.
Reverse proxy: Deploy another web server on your file server and configure your front end to act as a reverse proxy (ie. to dispatch download requests to the internal web server)
That is to say I would rather use an (Apache, Nginx, etc.) web server based approach instead of a Java/J2EE based one. For me it seems a better fit... Hence I would consult my sysadmin:)

Categories

Resources