jetty

Display an image using jetty web server from byte array

和自甴很熟 提交于 2019-12-08 11:15:09
问题 I have content of an image in a byte array, in a jetty servlet class. How could I display this image in a browser? 回答1: You will have something similar to this inside your sevlet byte[] imageBytes = ... response.setHeader("Content-Type", "image/jpg");// or png or gif, etc response.setHeader("Content-Length", imageBytes.lenght); response.getOutputStream().write(imageBytes); 回答2: This code worked. Thanks to "David Hofmann". //data is the content of the image in binary response.setContentType(

Why is Jetty hanging when I try to start it in debug mode?

烂漫一生 提交于 2019-12-08 09:50:54
问题 My problem is that when I try to launch Start.java in debug mode, Jetty hangs. Here is my Start.java file, taken from the Wicket quickstart page Server server = new Server(); SocketConnector connector = new SocketConnector(); // Set some timeout options to make debugging easier. connector.setMaxIdleTime(1000 * 60 * 60); ..... try { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); System.in.read(); System.out.println(">>> STOPPING EMBEDDED JETTY

Override contextPath on solr start from command line

人盡茶涼 提交于 2019-12-08 09:45:37
问题 Is it possible to override jetty "contextPath" property when starting Solr 5 using command line arguments? I want something like bin/solr -p 8983 -s "example/techproducts/solr" -a "-DcontextPath=/s" So that the base url will be http://localhost:8983/s To be precise, I want to override exactly contextPath property 回答1: Your question is about the context path of solr as jetty webapp. Instead of http://localhost:8983/solr/ you want to access solr via http://localhost:8983/s/ imho this is not

Enforce HTTPS with Embedded Jetty on Heroku

一笑奈何 提交于 2019-12-08 09:35:20
问题 We have a Java servlet, running with embedded Jetty, deployed to Heroku using the "SSL Endpoint" add-on. I have the requirement that all pages in the app be served over HTTPS, regardless of whether the user navigates to our app with http or https. The application recognizes requests made over https, but it also accepts http requests without redirecting (which it should not do). Also, if the user starts with an https connection, then whenever a form is posted and redirected to a "GET" request,

Jetty embed in Processing.org, static assets + POST

给你一囗甜甜゛ 提交于 2019-12-08 09:16:42
问题 I'm trying to embed Jetty in a Processing Sketch. So far I made it working to serve static files (a html directory in the Sketch folder). I want to react to one POST with a user input from one of the static pages. As I have no knowledge on Jetty and coming from a PHP & Ruby (RoR) web programing background I am very confused with the way things go in Jetty. I simply want something similar to routes where everything except e.g. "localhost:8080/post?string=whatever" is a static file. The post

Configuring Jersey + Jetty + JSP

点点圈 提交于 2019-12-08 08:16:46
问题 How do I configure this project so that it will be able to render JSP files? I would want to have URLS starting with /rest to route to jersey resources and have /* URLS serve JSP files. I don't have any web.xml in this project. Project folder ├───src │ └───main │ └───java/Main.java │ └───resources/HelloResource.java └───WEB-INF └───jsp/NewFile.jsp HelloResource.java package resources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/hello") public class

Adding headers to Jetty in Wiremock

╄→гoц情女王★ 提交于 2019-12-08 08:02:00
问题 I'm running into CORS issues using the Wiremock standalone jar. I call my mock service using jQuery ajax. Is it possible to add the required "Access-Control-Allow-Origin" header when starting up the server? 回答1: I got it to work by adding an options.json file in my mappings folder for the CORS preflight request { "request" : { "url" : "/myurl", "method" : "OPTIONS" }, "response" : { "status" : 200, "headers" : { "Access-Control-Allow-Origin" : "http://myorigin", "Access-Control-Allow-Headers"

Shutting down jetty using ShutdownHandler

时光怂恿深爱的人放手 提交于 2019-12-08 07:57:06
问题 I am using http://www.eclipse.org/jetty/documentation/current/shutdown-handler.html as a guide to try to shut down my jetty server, but I'm getting java.net.SocketException: Unexpected end of file from server when connection.getResponseCode(); is called and I don't know why. I'm using an xml configured server, so the way that the ShutdownHandler is added to the Handler chain is a little different, but it should be fine. I know that the ShutdownHandler is properly wired up to the handler chain

Why when I run a project created with Maven on Jetty it is not found (404)?

做~自己de王妃 提交于 2019-12-08 07:56:38
问题 I am started to read the Vaadin 7 CookBook and I got stuck at this point: We are done and we can run our new web application. Go to the root of the project where pom.xml file is located and run the following command. mvn jetty:start I experienced some problems right away when I ran that command: Maven: No plugin found for prefix 'jetty' in the current project... This helped me: http://blog.loxal.net/2014/03/maven-no-plugin-found-for-prefix-jetty.html add something like the following to your ~

Set Jetty session cookie name programmatically

馋奶兔 提交于 2019-12-08 07:55:27
问题 I'm running in this issue, how can I set session cookie name by code in Jetty 8? ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); sessionHandler = new SessionHandler(); sessionHandler.getSessionManager().setSessionCookie("JSESSIONID_"+runningPort); context.setSessionHandler(sessionHandler); Is wrong, in Jetty8 SessionManager setSessionCookie(String) was removed. 回答1: Here is the answer: ServletContextHandler context = new ServletContextHandler