Search Results

Search found 696 results on 28 pages for 'servlets'.

Page 11/28 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Java NIO Servlet to File

    - by Gandalf
    Is there a way (without buffering the whole Inputstream) to take the HttpServletRequest from a Java Servlet and write it out to a file using all NIO? Is it even worth trying? Will it be any faster reading from a normal java.io stream and writing to a java.nio Channel or do they both really need to be pure NIO to see a benefit? Thanks.

    Read the article

  • Why can't I wrap the ServletRequest when trying to capture JSP Output

    - by Patrick Cornelissen
    I am trying to dispatch in a servlet request handler to the JSP processor and capture the content of it. I am providing wrapper instances for the ServletRequest and ServletResponse, they implement the corresponding HTTPServletRequest/-Response interfaces, so they should be drop-in replacements. All methods are currently passed to the original Servlet Request object (I am planning to modify some of them soon). Additionally I have introduced some new methods. (If you want to see the code: http://code.google.com/p/gloudy/source/browse/trunk/gloudyPortal/src/java/org/gloudy/gloudlet/impl/RenderResponseImpl.java) The HttpServletResponse uses it's own output streams to capture the output. When I try to call request.getRequestDispatcher("/WEB-INF/views/test.jsp").include(request, response); With my request and response wrappers the method returns and no content has been captured. When I tried to pass the original request object it worked! But that's not what I need in the long run... request.getRequestDispatcher("/WEB-INF/views/test.jsp").include(request.getServletRequest(), response); This works. getservletRequest() returns the original Request, given by the servlet container. Does anyone know why this is not working with my wrappers?

    Read the article

  • Servlet request getparameter's performance

    - by Bob
    Hi, I noticed that my app is very slow sometimes, so I've done some tests. It's a very simple web app. One servlet gets some parameters than stores them. Everything's fine except one thing. It takes too long to get a parameter for the first time. It doesn't matter which parameter I try to get, but for the first time it is very slow. The strange thing is this doesn't happen always. Sometimes getting a parameter for the first time is not slow. My code looks like this request.getParameter("paramName"); request.getParameter("paramName2"); request.getParameter("paramName3"); Getting "paramName" is slow. Getting the others is very fast. By slow I mean : 200-800 millisec By very fast I mean: ~0 millisec (in the code snippet, I didn't write the performance test, but I'm using System.currentTimeMillis())

    Read the article

  • unable to compile a servlet in ubuntu

    - by codeomnitrix
    I am newbie to j2ee. I have download and installed j2eesdk-1_4_03-linux.bin in my ubuntu 10.04 distribution. and then i tried to code my first servlet in it as: import java.io.*; import javax.servelet.*; import javax.servelet.http.*; public class HowdyServelet extends HttpServelet{ public void doGet(HttpServeletRequest request, HttpServeletResponse response) throws IOException, ServeletException{ PrintWriter out = response.getWriter(); response.setContentType("text/html"); out.println("<html>"); out.println("<head><title>howdy</title></head>"); out.println("<body>"); out.println("<center><h1>Howdy</h1></center>"); out.println("</body>"); out.println("</html>"); } } and here are the environment variables i set after installation: 1. J2EE_HOME=/home/vinit/SUNWappserver 2. JAVA_HOME=/home/vinit/SUNWappserver/jdk 3. CLASSPATH=/home/vinit/SUNWappserver/lib and now i tried to compile the servlet using javac HowdyServelet.java But i got following errors: HowdyServelet.java:2: package javax.servelet does not exist import javax.servelet.*; ^ HowdyServelet.java:3: package javax.servelet.http does not exist import javax.servelet.http.*; ^ HowdyServelet.java:5: cannot find symbol symbol: class HttpServelet public class HowdyServelet extends HttpServelet{ ^ HowdyServelet.java:6: cannot find symbol symbol : class HttpServeletRequest location: class HowdyServelet public void doGet(HttpServeletRequest request, HttpServeletResponse response) throws IOException, ServeletException{ ^ HowdyServelet.java:6: cannot find symbol symbol : class HttpServeletResponse location: class HowdyServelet public void doGet(HttpServeletRequest request, HttpServeletResponse response) throws IOException, ServeletException{ ^ HowdyServelet.java:6: cannot find symbol symbol : class ServeletException location: class HowdyServelet public void doGet(HttpServeletRequest request, HttpServeletResponse response) throws IOException, ServeletException{ ^ 6 errors So how to compile this servlet. Thanks in advance.

    Read the article

  • Using a Filter to serve a specific page?

    - by user246114
    Hi, I am using a class which implements Filter for my jsp stuff. It looks like this: public class MyFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.getRequestDispatcher("mypage.jsp").forward(request, response); } } So the target, "mypage.jsp", is just sitting in my top-level directory. The filter works fine if I'm entering urls like: http://www.mysite.com/foo http://www.mysite.com/boo but if I enter a trailing slash, I'll get a 404: http://www.mysite.com/foo/ http://www.mysite.com/boo/ HTTP ERROR: 404 /foo/mypage.jsp RequestURI=/foo/mypage.jsp it seems if I enter the trailing slash, then the filter thinks I want it to look for mypage.jsp in subfolder foo or boo, but I really always want it to just find it at: http://www.mysite.com/mypage.jsp how can I do that? Thank you

    Read the article

  • View Body not showing in Spring 3.2

    - by Dennis Röttger
    I'm currently trying to get into Java Web Development in general in Spring more specifically. I've set up my project as follows - hello.jsp: <html> <head> <title>Spring 3.0 MVC Series: Hello World - ViralPatel.net</title> </head> <body> <p>ABC ${message}</p> </body> </html> HelloWorldController.java: package controllers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class HelloWorldController { @RequestMapping("/hello") public ModelAndView helloWorld() { String message = "Hello World, Spring 3.0!"; System.out.println(message); return new ModelAndView("hello", "message", message); } } web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>Spring3MVC</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>spring</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> </web-app> spring-servlet.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="controllers" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans> I can start up the Server just fine and navigate to hello.html, which is resolved by the servlet to give me hello.jsp, the title of the .jsp shows (Spring 3.0 MVC Series: etc. etc.), alas, the body does not. Not the JSTL-Variable and not the "ABC" either. I've implemented jstl-1.2 in my lib-folder.

    Read the article

  • Cookie questions in Java

    - by user220201
    Hi, How do I differentiate between multiple cookies set through my site? I am setting two kinds of cookies one to see if the user has visited the site or not and an other one for authentication. How do I differentiate between these two? I get both of them when someone accesses a page after authentication. Do I add extra information to the Cookie Value or is there some other way? I understand the setName() function will change the name (from jsessionid) for every cookie from then on. Am I correct? Pav

    Read the article

  • Servlet xxx is not available

    - by hguser
    In the web.xml of my web app I have configed the server as following: The web.xml However when I request this servlet ,I got a error which tells me "Servlet SOS is not available",but I am sure this servlet do exist in the WEB-INFO/lib/sos.jar. And I have seen the initialization work under the servelt from the logs. I wonder why can not tomcat find the sevlet?

    Read the article

  • Servlet receives OPTIONS instead of GET requests from jQuery?

    - by Urs
    All I want to achieve is to implement a servlet providing a json feed for my fullcalendar application. When I inspect http://arshaw.com/js/fullcalendar/examples/json.html with Bugzilla, I see that GET-requests are sent to receive the json feed. However, when I use this example within my scenario, fullcalendar seems to send OPTIONS-requests. The only difference is that I replaced "events: "json-events.php" with "http://localhost:8080/CalendarServletTest/HelloWorldServlet" (the url of my servlet). What do I miss? Or is this really a bug?

    Read the article

  • HttpPost request unsuccessful

    - by The Thom
    I have written a web service and am now writing a tester to perform integration testing from the outside. I am writing my tester using apache httpclient 4.3. Based on the code here: http://hc.apache.org/httpcomponents-client-4.3.x/quickstart.html and here: http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fundamentals.html#d5e186 I have written the following code. Map<String, String> parms = new HashMap<>(); parms.put(AirController.KEY_VALUE, json); postUrl(SERVLET, parms); ... protected String postUrl(String servletName, Map<String, String> parms) throws AirException{ String url = rootUrl + servletName; HttpPost post = new HttpPost(url); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); for(Map.Entry<String, String> entry:parms.entrySet()){ BasicNameValuePair parm = new BasicNameValuePair(entry.getKey(), entry.getValue()); nvps.add(parm); } try { post.setEntity(new UrlEncodedFormEntity(nvps)); } catch (UnsupportedEncodingException use) { String msg = "Invalid parameters:" + parms; throw new AirException(msg, use); } CloseableHttpResponse response; try { response = httpclient.execute(post); } catch (IOException ioe) { throw new AirException(ioe); } String result; if(HttpStatus.SC_OK == response.getStatusLine().getStatusCode()){ result = processResponse(response); } else{ String msg = MessageFormat.format("Invalid status code {0} received from query {1}.", new Object[]{response.getStatusLine().getStatusCode(), url}); throw new AirException(msg); } return result; } This code successfully reaches my servlet. In my servlet, I have (using Spring's AbstractController): protected ModelAndView post(HttpServletRequest request, HttpServletResponse response) { String json = String.valueOf(request.getParameter(KEY_VALUE)); if(json.equals("null")){ log.info("Received null value."); response.setStatus(406); return null; } And this code always falls into the null parameter code and returns a 406. I'm sure I'm missing something simple, but can't see what it is.

    Read the article

  • How to handle security constraints using GWT 2.1's RequestFactory?

    - by Marc
    I am currently developing a GWT 2.1 application that is to be deployed on Google App Engine. I would like to realise the server communication using the new RequestFactory. Now my question is how to handle fine-grained security issues in this context? Some server actions (of those declared in the RequestContext stubs) shall be restricted to certain users (possibly depending on the parameters of the remote call). If a call is unauthorised, I would like the client to show a login page (so that one may log in as a different user, for example). From the Expenses example, I know how to implement an automatic redirection to a login page, but in this example, the security model is quite simple: A client is allowed to access the servlet if and only if a user is logged in. Shall I raise a custom UnAuthorizedException in my server-side service? Where should I intercept this exception? (Can I do this in a servlet filter like the GaeAuthFilter of the Expenses example?)

    Read the article

  • http streaming using java servlet

    - by Shamik
    I have a servlet based web application which produces two sets of data. One set of data in the webpage which is essential and other set which is optional. I would like to render the essential data as fast as possible and then stream the optional data. I was thinking of writing the essential data to the output stream of HttpServletRequest and then call HttpServletRequest.flushBuffer() to commit the response to the client, but do not return from the servlet code, but instead create the optional data , write that to the outputstream again and then return from servlet code. What are the things that could go wrong in this scheme ? Is this a standard practice to achieve this goal?

    Read the article

  • Restoring web session in struts2

    - by bozo
    Hi, I have a classical scenario of a website and payment gateway integration, where the request for payment is sent to payment processor, and the payment processor calls back my application once it's done with some parameters I passed to it in the original request. Among parameters, we pass jsessionid and we expect that when the remote server makes request to our server (via customer browser redirect to our server) that the session will be the same as the session used to send the initial payment request. This does not happen, we have two different sessions, although the payment processor includes our original jsessionid in the request to us (https://blabla/?jsessionid=something). How should we go about recreating a session in struts2, in the only thing that connects the 'OLD' and 'NEW' session is the jsessionid in the request URL? Any ideas? Is this possible at all or is the 'OLD' session data deleted when the user moves away from our server onto a completely different domain of a payment processor with their data-entry form? This would explain our innability to recreate the session. Thanks a lot for your replies.

    Read the article

  • Parse error in application web.xml

    - by saloni
    I am making a simple servlet program and when i started my tomcat I m getting the error "java.lang.IllegalArgumentException:" and Parse error in application web.xml. and in web.xml http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" sample Samplelass SampleClass SampleClass /sample sample/page/form.jsp

    Read the article

  • applet communication using post method

    - by mithun1538
    I have an applet that is communicating with a servlet. I am communicating with the servlet using POST method. My problem is how do I send parameters to the servlet. Using GET method, this is fairly simple ( I just append the parameters to the URL after a ?). But using POST method how do I send the parameters, so that in the servlet side, I can use the statement : message = req.getParameter("msg"); In the applet side, I establish POST method connection as follows : URL url = new URL(getCodeBase(), "servlet"); URLConnection con = url.openConnection(); con.setDoInput(true); con.setDoOutput(true); con.setUseCaches(false); con.setRequestProperty("Content-Type","application/octet-stream");

    Read the article

  • JSP doGet not called from form

    - by RadnaOdela
    I have this code on my JSP page <form action="LoginServlet" method="get"> <input type="text" name="username" /> <input type="text" name="password" /> <input type="submit" value="Submit" /> </form> and when I press Submit I get: The page cannot be displayed The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings. and LoginServlet.doGet method doesn't get called. But then when I press Enter again (in address bar) my doGet method gets called. What is wrong? I am using JEE eclipse and Tomcat

    Read the article

  • "session" bean scope in a web application - reliable ?

    - by EugeneP
    Can you rely on this scope and be sure that every time 1) a new session starts, the Spring bean will be initialized with default values 2) while session is kept alive, the current object will store its state during session life, will never be lost or corrupted and can always be got with [webappcontext].getBean ?

    Read the article

  • Configuring web.xml for webservices and servlet.

    - by Win Man
    Hi, I am new to Restlets. Trying to configure the web.xml (on JBoss). I have 2 entries, one for a servlet (got nothing to do with webservices) other for webservices, using Restlet. Here are the entries.. <servlet> <servlet-name>AuthenticationServlet</servlet-name> <servlet-class>com.safeid.web.server.api.servlet.AuthenticationServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AuthenticationServlet</servlet-name> <url-pattern>/authenticate/*</url-pattern> </servlet-mapping> <!-- Start of Entries for the REST Web Services. --> <context-param> <param-name>org.restlet.application</param-name> <param-value>com.safeid.web.server.SafeIDRouterApplication</param-value> </context-param> <servlet> <servlet-name>RestletServlet</servlet-name> <servlet-class>com.noelios.restlet.ext.servlet.ServerServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>RestletServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <!-- END of Entries for the REST Web Services.--> Both don't work together. In the above setup the Restlet works. However when I change the RestletServlet /* to something like <servlet-mapping> <servlet-name>RestletServlet</servlet-name> <url-pattern>/credential/*</url-pattern> </servlet-mapping> the Restlet stop working and the AuthenticationServlet works fine. What am I missing here?

    Read the article

  • EOFException in ObjectInputStream Only happens with Webstart not by java(w).exe ?!

    - by Houtman
    Hi, Anyone familiar with the differences in starting with Webstart(javaws.exe) compared to starting the app. using java.exe or javaw.exe regarding streams ? This is the exception which i ONLY get when using Webstart : java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source) at java.io.ObjectInputStream.readStreamHeader(Unknown Source) at java.io.ObjectInputStream.<init>(Unknown Source) at fasttools.jtools.dss.api.core.remoting.thinclient.RemoteSocketChannel.<init>(RemoteSocketChannel.java:77) This is how i setup the connections on both sides //==Server side== //Thread{ Socket mClientSocket = cServSock.accept(); new DssServant(mClientSocket).start(); //} DssServant(Socket socket) throws DssException { try { OutputStream mOutputStream = new BufferedOutputStream( socket.getOutputStream() ); cObjectOutputStream = new ObjectOutputStream(mOutputStream); cObjectOutputStream.flush(); //publish streamHeader InputStream mInputStream = new BufferedInputStream( socket.getInputStream() ); cObjectInputStream = new ObjectInputStream(mInputStream); .. } catch (IOException e) { .. } .. } //==Client side== public RemoteSocketChannel(String host, int port, IEventDispatcher eventSubscriptionHandler) throws DssException { cHost = host; port = (port == 0 ? DssServer.PORT : port); try { cSocket = new Socket(cHost, port); OutputStream mOutputStream = new BufferedOutputStream( cSocket.getOutputStream() ); cObjectOut = new ObjectOutputStream(mOutputStream); cObjectOut.flush(); //publish streamHeader InputStream mInputStream = new BufferedInputStream( cSocket.getInputStream() ); cObjectIn = new ObjectInputStream(mInputStream); } catch (IOException e) { .. } .. } Thanks [EDIT] Webstart console says: Java Web Start 1.6.0_19 Using JRE version 1.6.0_19-b04 Java HotSpot(TM) Client VM Server is running same 1.6u19

    Read the article

  • how to ouput text to java console from servlet

    - by mithun1538
    I have a servlet. But it is not working as desired. Hence for debugging purposes, I want to print statements to the java console(the one that can be opened using the java icon in taskbar). However, if I use System.out.println("message"), it doesnt display in java console. Is there any alternative way where I can display messages to the console from the servlet? Or can anyone suggest me an alternative way to display messages to any other console?

    Read the article

  • Spring MVC, forward

    - by aauser
    Is there any difference between public class Controller1 extends AbstractController { @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { return new AnotherController().handleRequest(request, response); } } and @Controller public class Controller1 { @RequestMapping ... public String handleRequest() { return "forward:/path_to_my_another_controller"; } }

    Read the article

  • Logic for controll concurrent in block/method

    - by Hlex
    1)My environment is web application, I develop servlet to receive request. A) In some block/method i want to control concurrent to not greater than 5 B) if there are 5 request in that block , the new coming must wait up to 60 second then throws error C) if there are sleep/waiting request more then 30, the 31th request will be throwed an error How I do this? 2)(Optional Question) from above I have to distribute control logic to all clustered host. I plan to use hazelcast to share the control logic (e.g. current counter) I see they provide BlockingQueue & ExectorService but I have no idea how to use in my case. Please recommend if you have idea.

    Read the article

  • How a servlet can get the absolute path to a file outside of the servlet?

    - by WolfmanDragon
    We have been using System.getProperties("user.dir") to get the location of a properties file. Now that it has been deployed on Tomcat(via servlet), the System call is giving the location as tomcat and not at the location at where the properties file exist. How can we call the the properties file dynamically? Given: Tomcat is not the only way the app will be deployed We have no control on where the app may be placed. Relative paths will not work as that Vista is being used and Vista breaks relative paths. This must work on all OS, including(but not limited to) Linux, XP and Vista. EDIT I implied this, but in case I was not clear enough, I have no way of knowing the path String.

    Read the article

  • Security when using GWT RPC

    - by gerdemb
    I have an POJO in Google Web Toolkit like this that I can retrieve from the server. class Person implements Serializable { String name; Date creationDate; } When the client makes changes, I save it back to the server using the GWT RemoteServiceServlet like this: rpcService.saveObject(myPerson,...) The problem is that the user shouldn't be able to change the creationDate. Since the RPC method is really just a HTTP POST to the server, it would be possible to modify the creationDate by changing the POST request. A simple solution would be to create a series of RPC functions like changeName(String newName), etc., but with a class with many fields would require many methods for each field, and would be inefficient to change many fields at once. I like the simplicity of having a single POJO that I can use on both the server and GWT client, but need a way to do it securely. Any ideas?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >