Search Results

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

Page 14/28 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • In html <a href> tag, how to call servlet before opening file dialog for download (save as)?

    - by deepthinker121
    Hi All, I am developing a web-app where I want to provide a download link to users - so they can download a zip file from my server. Now, my requirement is that I want to execute some processing logic contained in a servlet before displaying the file dialog to the user for 'zip' files. So If I write <a href="abc.zip".......> then it opens a file dialog asking the user to select the location where this file can be saved But if I want a servlet's doGet method to do some preprocessing - say like building the zip file , then how can I first call the servlet and then open the file dialog. Will the following snippet work? <a href="MyHandlerServlet;abc.zip".......> Thanks for your help !!

    Read the article

  • Java Servlet connecting to SQL Server tutorial?

    - by phill
    Can anyone recommend a tutorial on how to write a Java Servlet which connects to MS SQL server and manages data? I'm trying to write something which pulls products out of one database and inserts them into a stored procedure located on another database. Thanks in advance.

    Read the article

  • HttpsCookieFilter - IllegalStateException: getOutputStream() has already been called for this response

    - by Mat Banik
    Following exception is thrown every once in a while and it shows up in localhost log file in tomcat log directory. If anyone know how to get rid of it, all help would be appreciated. BTW the filter is working fine I just don't know why this exception is happening. Stack trace: java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:611) at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198) at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112) at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:366) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:283) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:233) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:65) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176) at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:57) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:109) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) //Here is the servlet I suspect is trowing the exception. at package.HttpsCookieFilter.doFilter(HttpsCookieFilter.java:38) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:886) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:721) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2256) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:717) The HttpsCookieFilter class: public class HttpsCookieFilter implements Filter { private static Logger log = Logger.getLogger(HttpsCookieFilter.class); @Override public void destroy() { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; final HttpSession session = req.getSession(false); if (session != null) { setCookie(req, res); } try{ chain.doFilter(request, response); // <- Exception thrown from here }catch (IllegalStateException e){ log.warn("HttpsCookieFilter redirect problem! ", e); } } @Override public void init(FilterConfig arg0) throws ServletException { } private void setCookie( HttpServletRequest request, HttpServletResponse response) { Cookie cookie = new Cookie("JSESSIONID", request.getSession(false).getId()); cookie.setMaxAge(-1); cookie.setPath(getCookiePath(request)); cookie.setSecure(false); response.addCookie(cookie); } private String getCookiePath(HttpServletRequest request) { String contextPath = request.getContextPath(); return contextPath.length() > 0 ? contextPath : "/"; } } web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <listener> <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class> </listener> <filter> <filter-name>httpsCookieFilter</filter-name> <filter-class>com.iteezy.server.web.servlet.HttpsCookieFilter</filter-class> </filter> <filter-mapping> <filter-name>httpsCookieFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>filterChainProxy</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>filterChainProxy</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ... The reason for integrating this filter comes from Spring security FAQs: I'm using Tomcat (or some other servlet container) and have enabled HTTPS for my login page, switching back to HTTP afterwards. It doesn't work - I just end up back at the login page after authenticating. This happens because sessions created under HTTPS, for which the session cookie is marked as “secure”, cannot subsequently be used under HTTP. The browser will not send the cookie back to the server and any session state will be lost (including the security context information). Starting a session in HTTP first should work as the session cookie won't be marked as secure.

    Read the article

  • tomcat resource missing, servlet not running

    - by user2837260
    import javax.servlet.*; import java.io.*; public class MyServlet implements Servlet { public void init(ServletConfig con) {} public void service(ServletRequest req, ServletResponse res) throws IOException,ServletException { res.setContentType("text/html"); PrintWriter out=res.getWriter(); String s="blah"; String s1="blah"; out.println("<html><body>"); if((s.equals(req.getParameter("firstname")))&&(s1.equals(req.getParameter("pwd")))) out.println("passwords match"); else out.println("password and name combo does not match"); out.println("</body></html>"); } public void destroy() {} public ServletConfig getServletConfig() { return null;} public String getServletInfo() { return null;} } this is my java file with the servlet class.its saved with the name MyServlet.java and so is the class file. and here is the xml file: <web-app> <servlet> <servlet-name>demoo</servlet-name> <servlet-class>MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>demoo</servlet-name> <url-pattern>/demo</url-pattern> </servlet-mapping> </web-app> i have made the folder as WEB-INF and then classes... WEB-INF also contains the .xml file but when i try to run the servlet , it says resource not found ps- i am already looking for the servlet with the name :demo localhost:8081/s1/demo* s1 is the war file * a html file in the war file seems to run fine on the server though. *

    Read the article

  • java servlet: generate zip file from BLOBs

    - by Zack
    I'm trying to zip a large number of pdf files (stored as BLOBs in the DB) and then return the zip as an attachment to the user. What's the best way to do this without running into memory issues? Another note: I actually need to merge some PDFs prior to adding them to the ZipOutputStream. Therefore, a couple PDFs will need to be stored in memory at a time. I assume it would be best to then store them as temporary files on the server before zipping them all?

    Read the article

  • Information sent in an HTML form

    - by dedalo
    Hi, I've a HTML file that shows to the user the contents of a database (it is shown as a table). The user can choose one of the rows.When this is done the selection made by the user is sent to a servlet that will work with that information. Imagine that this servlet is going to look for files related to the information chosen by the user. What I'd like to do is to provide the user with the option of also choosing the number of files that are going to be looked for by the servlet. That way the user should be able to choose one of the rows shown in the table and should also be able of typing the numers of files that are to be looked for. So far I'm able to send to the servlet what the user chooses in the table, but I'd like to know if it is possible to attach to this information the number of files requested. Thanks

    Read the article

  • ClassNotFoundException in Tomcat console when using jawr

    - by Jaya
    Hi, I am using Tomcat from Eclipse. When i try to start the server I am getting the following error in the console: java.lang.ClassNotFoundException: net.jawr.web.servlet.JawrServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516) When i deploy the war file in the Tomcat server outside of eclipse it is not having any problems. I am only getting this problem when i am trying to start tomcat from eclipse with jawr. Please let me know the solution for this problem. Thanks in advance, Jaya

    Read the article

  • How to pass values from client side to server side ?

    - by manojp1988
    Hi All, I got a situation to transfer values from jsp to servlet's action class. Previously we did it using <input type="hidden" id="name" value="manoj" /> we take this value in action class by request.getParameter("name"). But now we couldn't pass value like "Hi\n i am\n Manoj". Since it has new line included in the string we couldn't take it like this to action. So how I can take value like this to action or is there any way other than hidden input? Thanks .

    Read the article

  • HibernateFilter.doFilter ServletException?

    - by Austin R
    I have pretty much zero experience setting up servers, but currently my job is to set one up (don't ask why). It's an an apache-tomcat6 server. I followed some instructions step by step, and when it came time to test that everything was working, here's what I got: I know this is a bit of a shot in the dark, but does anyone know what I can do to fix this? Please let me know if there's any further information I can provide to help!

    Read the article

  • displaying data from database in to text box

    - by srinayak
    I have 2 JSP pages as below: projectcategory.jsp <% Connection con = DbConnect.connect(); Statement s = con.createStatement(); ResultSet rs = s.executeQuery("select * from projectcategory"); %> <DIV class="TabbedPanelsContent" align="center"> <TABLE border="1"> <TR> <TH>CATEGORY ID</TH> <TH>CATEGORY NAME</TH> <TH>Edit/Update</TH> </TR> <% while (rs.next()) { %> <%String p=rs.getString(1);%> <TR> <TD><%=rs.getString(1)%></TD> <TD><%=rs.getString(2)%></TD> <TD> <FORM action="EditPcat.jsp?pcatid=p"><INPUT type="submit" value='edit/update'></INPUT> </FORM> </TD> </TR> <% } %> </TABLE> </DIV> another is Editpcat.jsp: </head> <body> <%String s=request.getParameter("p"); %> <form action="ProjCatServlet" method="post"> <div align="right"><a href="projectcategory.jsp">view</a></div> <fieldset> <legend>Edit category</legend> <table cellspacing="2" cellpadding="2" border="0"> <tr> <td align="left">Category Id</td> <td><input type="text" name="pcatid" value="<%=s%>" ></td> </tr> <tr> <td align="right">Category Name</td> <td><input type="text" name="pcatname"></td> </tr> <tr> <td><input type="submit" value="submit"></td> </tr> </table> <input type="hidden" name="FUNCTION_ID" value="UPDATE"> </fieldset> </form> How to display value from one JSP page which we get from database in to text box of another JSP?

    Read the article

  • Using <input type=file /> with J2EE/MySQL Backend

    - by Mark Hazlett
    Hey everyone, I'm wondering how I can hook up an input type=file to send a picture back to a backend servlet that will eventually be stored in a MySQL database as a BLOB? In other words, how can I upload a picture using the input and send that back to the servlet to insert into the database as a BLOB type? Thanks

    Read the article

  • Need help in using Eclipse JEE version to develop a servlet project

    - by michael
    Hi, I have downloaded eclipse jee version (3.5) and I would like to use it to develop a servlet project on tomcat. So I * install tomcat and add it as my server in my eclipse environment. * create a Dynamic Web Project called 'TestServlet' * create a new servlet called 'MainServlet' and then I deploy my project to the tomcat server via eclipse and 'run the server in debug' mode. But when I use the browser to hit 'http://localhost:8080/TestServlet/MainServlet' I see no resource found (that page is generated by Tomcat, so I know my Tomcat is running). Can you please tell me what am I missing? Or how can I trouble shoot my problem? I think it must be some path /name is not set correctly.

    Read the article

  • Naming Exception when bounding to the home interface

    - by Nila
    Hi! I'm new to ejb. I'm trying to call the ejb from the servlet. But, I'm getting the NamingException. I'm directly running the servlet from the netbeans to check whether it is calling the ejb. But, it is not working. I'm getting the exception as home interface not bound. What is the solution for this?

    Read the article

  • Embedding XSL Stylesheet into XML

    - by user700996
    I have the following XML: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="http://www.fakedomain.com/sally.xsl"?> And the following content in sally.xsl: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:for-each select="documentcollection/document"> <p> <xsl:for-each select="rss/channel/item"> <xsl:value-of select="title"/><br /> <xsl:value-of select="description"/><br /> <xsl:value-of select="link"/><br /> </xsl:for-each> </p> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> However, the browser displays the XML as though the XSL line is not present. Do you know why the browser is ignoring the XSL stylesheet? Is the style sheet wrong? Thanks

    Read the article

  • reading html from an inputstream java

    - by randeel wimalagunarathne
    hello everyone, I am reading a html file using an inputstream from a java servlet. But the contents of the original and the read one are in a different format although when displayed in a web browser they are the same. These are the two links for the html files after reading output http://www.fileflyer.com/view/gQREGAe orginal output http://www.fileflyer.com/view/mWXHVAE Is there a way to get the original html when reading? why is this happening? my java code is as follows; InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(isr); String line = null; while ( (line = br.readLine()) != null) { System.out.println(line); } Any help would be greatly appreciated!! Thank you, rana.

    Read the article

  • Servlet mapping for ajax call parameters

    - by Woho87
    Hi guys! <servlet-mapping> <servlet-name>Test</servlet-name> <url-pattern>/GetContacts*</url-pattern> </servlet-mapping> I got a simple problem where I can't find any solution on the internet. I have a ajax calls that have the url http://localhost:80/Push/GetContacts?id=23..... The above servlet mapping is not correct for the AJAX call. it issues a http 404 not found call. What is the right syntax to enable my ajax call?

    Read the article

  • How to implement GCM in Google AppEngine?

    - by Broken System
    I'm a PHP Developer and Web Designer. In my work a partner asked me if I could set up a Google Cloud Messaging server. I read the documentation but couldn't find a clear tutorial to set up this server. I got no knowleadge about Java so it makes my job harder. I could "compile" a war file using ant as GCM Demo Tutorial says. But I can't deploy it to my AppEngine server to try it out (It's my first time using AppEngine too). Could you give me some steps to create my own GCM server? Sorry about my bad english. Thanks!

    Read the article

  • Error with connection in my database servlet

    - by Zerobu
    Hello, I am writing a Database servlet, all seems well except that there seems to be an error in my connection import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class DBServlet3 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void init() throws ServletException { super.init(); try { String jdbcDriverClass= getServletContext().getInitParameter( "jdbcDriverClass" ); if (jdbcDriverClass == null) throw new ServletException( "Could not find jdbcDriverClass initialization parameter" ); Class.forName( jdbcDriverClass ); } catch (ClassNotFoundException e) { throw new ServletException( "Could not load JDBC driver class", e ); } } @Override protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { RequestDispatcher dispatcher= request.getRequestDispatcher( "/db.jsp" ); ServletContext application= getServletContext(); ArrayList<String> names= new ArrayList<String>(); try { Connection connection= null; Statement statement= null; ResultSet results= null; try { String jdbcUrl= application.getInitParameter( "jdbcUrl" ); String jdbcUser= application.getInitParameter( "jdbcUser" ); String jdbcPassword= application.getInitParameter( "jdbcPassword" ); connection= DriverManager.getConnection( jdbcUrl, jdbcUser, jdbcPassword ); statement= connection.createStatement(); results= statement.executeQuery( "SELECT * FROM students" ); while (results.next()) { String name= results.getString( "name" ); names.add( name ); } } finally { if (results != null) results.close(); if (statement != null) statement.close(); if (connection != null) connection.close(); } } catch (SQLException e) { throw new ServletException( e ); } request.setAttribute( "names", names ); dispatcher.forward( request, response ); } @Override protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { String sql= "INSERT INTO students VALUES (" + request.getParameter( "id" ) + ", '" + request.getParameter( "name" ) + "')"; sql= "INSERT INTO students VALUES (?, ?, ?, ?)"; PreparedStatement statement= connection.prepareStatement( sql ); //error on this line statement.setString( 1, request.getParameter( "id" ) ); statement.setString( 2, request.getParameter( "name" ) ); } }

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >