Servlets struts.action.excludePattern not working,

struts.action.excludePattern is not working for me in Struts 2, i had place servlet cal in form action, form will submit on hyperLink click. struts.xml: <constant name="struts.action.excludePattern" value="/PunchoutOrder"/> web.xml <servlet> <description></description> <display-name>PunchoutOrder</display-name> <servlet-name>PunchoutOrder</servlet-name> <servlet-class>com.PunchoutOrder</servlet-class> </servl

Servlets populate the combobox dynamically in ExtJs

I want to populate the combobox dynamically based on the data I received from thr Url(which is servlet) Below is my ExtJS code : { xtype:'combo', id: 'shoutoutsTags', fieldLabel: 'Tag', value: '', mode: 'local', width: 200, store: new Ext.data.JsonStore({ id:'ms', url:'http://localhost:8080/ezdi/extServlet', //totalProperty:'totalCount', root:'rows', fields:[ {name:'un'},

Servlets Servlet/JSP Error Pages

I'm just looking for some advice on the use case scenarios for creating your own error pages. I've been experimenting with creating error pages and mapping them to codes, and it seems extremely simple to do, yet I've noticed a lot of web sites that don't bother, they simply rely own the browser default. I'm curious as to whether or not there is a standard or set of guidelines for which apporach is best? For such a simple feature, it's extremely underused imho

Servlets Inject CDI Session Bean in Servlet

I'm getting in my project inject (@ Inject) CDI Beans scopes Request and Session in a servlet. The problem is that for session beans CDI I'm not getting that states remain. I try to modify the state of the bean from my servlet but when I try to recover from a page is as if the servlet had failed to change state. Someone could help me?

Servlets Refreshing page quite a few times takes server down

I have a website/webapp which I developed in JSP/Servlets. On the main the data is collected from the database, so I run the Servlet first to collect data and send it to the JSP. (works fine) The problem is few minutes ago I kept F5 pressed for a while (i.e. refreshed the page quite a few times). Now the server is down and the website displays a Service Temporarily Unavailable message. The bandwidth limit of the account is unlimited, still its saying the account has exceeded the bandwidth limit.

Servlets How to stop the entire java webapp when the servlet fails to initialize

I want my web application to fail on startup if any of my servlet fails to initialize. I would expect if I throw an exception form the Servlet.init() method it would cause the entire app to fail, but apparently it doesn't. The web container (Tomcat 7 in my case) just fails to load that particular servlet, but the application is reported to be successfully deployed anyway. It behaves as expected if an exception thrown from e.g. ServletContextListener.contextInitialized() method, but why the exce

Servlets Websphere 8.5 Liberty Profile - Servlet API setLocale

I'm using the Websphere 8.5 Liberty Profile with Fixpack 1 and encountered the following problem that seems to violate the Servlet API. The Content-Language response header is not set after response.setLocale(), if the response body is being written on the response output stream (HttpServletResponse#getOutputStream()). It works fine if the body is written on the response writer instead (HttpServletResponse#getWriter()) The following JSP does not return a Content-Language response header: <

Servlets JSF context from Servlet

I have a JSF2 controller/bean/view that is invoked the standard JSF way. Now I have a need to access this logic from a legacy part of the app that knows servlets and URL params only. I thought of creating a "loader.xhtm" view that bridges the gap between non-jsf requester and the jsf part of the app. Loader will take URL params and make the necessary JSF post to backing bean. etc. One downside of this approach is - it's one extra client/server hop, a programmatic redirect. However it is simple

Servlets Replace web.xml in Vaadin

I use Vaadin 7. I want to change the default Servlet in my application. What I did is the following : public class MyVaadinApplication extends UI { @WebServlet(urlPatterns = "/*", asyncSupported = true) @VaadinServletConfiguration(productionMode = true, ui = MyVaadinApplication.class) public static class Servlet extends VaadinServlet { @Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); /* * Vaadin Ses

Servlets Karaf and Eclipse Equinox OSGI services

In a series of blogs on Java webframeworks, which should play nicely in OSGI, I am taking a close look at Karaf. My test case is pretty straight-forward, deploy a Servlet on Karaf. There are different HTTPService implementations for OSGI, I am trying with the Equinox implementation (org.eclipse.osgi.services). My bundle loads nicely without the HTTPService dependencies, but when I add dependencies for HTTPService [3], Servlet and try to install the feature [1], I run into trouble [2]. Not

Servlets Log4j2 with Websphere Application Server org.apache.logging.log4j.web.Log4jServletContainerInitializer not a subtype

We have an application which uses Log4j2 and running on WAS 8.5. We have selected the class loading option as PARENT_LAST, so the jar files will be picked up from WEB-INF/lib. We are error getting the below error when starting up the server. com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider org.apache.logging.log4j.web.Log4jServletContainerInitializer

Servlets why request.getParameter() giving me double decoded value

I have a double encode GET Parameter. I am using request.getParameter(). The parameter is double encoded using UTF-8 encoding. Why am I not getting single encoded string. Eg. param=%3D_Test%253Dtest It should give me result as '=_Test%3Dtest'. But what I am having is '=_Test=test'

Servlets Set servlet as default home page in web.xml

I've a servlet registered in web.xml as below. <servlet> <servlet-name>Manager</servlet-name> <servlet-class>Manager</servlet-class> </servlet> <servlet-mapping> <servlet-name>Manager</servlet-name> <url-pattern>/RequestManager</url-pattern> </servlet-mapping> Basically I want to call this servlet as my default home page when I open http://localhost:8080/appname. So, I tried registering it as welcome file

Servlets Servlet Filter login redirection infinite loop

I am experimentig with servlet filters. I have created two JSP pages - Home and Login. I want to create the following flow: When accessing the Home page without credentials in the session -> redirect to Login page. When entering the correct credentials (compare them against hardcoded constants) redirect to the Home page. When entering incorrect credential - redirect to Login page again. Here is my code so far, I have an issue with an infinite loop when entering the home page directly, becaus

Servlets Grails 3, change contextPath dynamically (servletContext?)

I have a problem changing the contextPath of an grails 3 web application dynamically. It's working if I change it in groovy.gsp (server.contextPath = "/myApp"), but i need to deploy it with different names like that: myApp_A.war => IP:Port/myApp_A myApp_B.war => IP:Port/myApp_B In can get the direcory name (llike: "myApp_A" for myApp_A.war) and read the right properties file dynamically (myApp_A.properties). After that I'm trying to set the context path for this instan

How to implement OpenSAML library in a Web Application using servlets for SSO

I have a Web Application built with Servlet , I don't know how to implement SAML for Web SSO and there is no perfect guideline to use it in servlets. Where to initiate or initialize the openSAML and how to redirect to IDP from login page and where to consume the responses ,. I have seen a couple of samples like spring-security-saml but they none of the examples are servlet based. If I get a suitable example which uses servlet it would be a great help .

Servlets Adding Resteasy-multipart-provider to my POM breaks previously working REST Services

I need a REST Service to handle File uploads. I added the RESTEasy Multipart Provider dependency: <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider --> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-multipart-provider</artifactId> <version>3.1.4.Final</version> </dependency> This somehow caused my other REST Services to stop working properly, and they now return erro

Jetty does not load any servlets

I'm using OpenJRE 11 and Jetty 9 as installed on Ubuntu Server LTS. With this source: $ find . ./build.gradle ./gradlew ./src ./src/main ./src/main/java ./src/main/java/com.example ./src/main/java/com.example/servlet ./src/main/java/com.example/servlet/ExampleServlet.java ./src/main/webapp ./src/main/webapp/WEB-INF ./src/main/webapp/WEB-INF/jetty-web.xml ./src/main/webapp/WEB-INF/web.xml build.gradle: plugins { id 'java' id 'war' } repositories { jcenter() } group 'com.example'

Servlets @WebServlet fails in Netbeans 11.0 with java.lang.RuntimeException: com.example.NewServlet.<init>(NewServlet.java:1)

Some kind of nightmare - can not launch primitive servlet on Apache Tomcat 9.0.22 (or Glassfish 5.0.1) and Apache NetBeans IDE 11.0 (Build incubator-netbeans-release-404-on-20190319) by using servlet annotations.. Using JDK 1.8u221. Here is the code: @WebServlet(name = "NewServlet", urlPatterns = {"/meow"}) public class NewServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { resp

Servlets In Servlet the "request.getParts().stream()..." adds a "empty" Part object

In my JSP I have a form where the user can upload a file. <form method="post" action="linkToAction" role="form" enctype="multipart/form-data"> <input name="files" type="file" class="form-control-file" multiple="true" > </form> Reading this answer, in my servlet I get the files uploaded: List<Part> fileParts = request.getParts().stream().filter(part -> "files".equals(part.getName())).collect(Collectors.toList()); If the user doesn't upload anything, I would expe

Servlets When I am running the following code, I am receiving an Servlet 404 error

I am running the following code, Which is html version, It shows the name and age boxes. <!-- Main.html --> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>A First page</title> </head> <body> <form action="Thanks.jsp" method="get"&g

Servlets Processing Java servlet 'javax.servlet' package not found

Not a very common implementation, but using Processing as a Java Servlet has been discussed in previous posts before (1, 2). I have been developing a program in Processing to use as a Java servlet. However, when I have code (such as like the first linked example) in a Processing sketch, I get the error message The package 'javax.servlet' does not exist. You might be missing a library. I have Tomcat 5.5 service running on XP, and my environment variables are as follows CLASSPATH = C:\tomca

Servlets Compojure: getting the body from a POST request from which the Content-Type header was missing

Given this snippet: (defroutes main-routes (POST "/input/:controller" request (let [buff (ByteArrayOutputStream.)] (copy (request :body) buff) ;; --- snip The value of buff will be a non-empty byte array iff there's the Content-Type header in the request. The value can be nonsencial, the header just has to be there. However, I need to dump the body (hm... that came out wrong) if the request came without a content type, so that the client can track down th

Servlets Catch-all (wildcard) servlet url-pattern overrides file extension patterns

I would like to achieve the following: /webapp-context/Page-1 -> Handled by my custom "ContentServlet" /webapp-context/Another-Page -> Handled by my custom "ContentServlet" /webapp-context/Page-with-long-title -> Handled by my custom "ContentServlet" /webapp-context/_cms/<something>.zul -> Handled by ZK framework My latest attempt looks like this (web.xml extract): <servlet-mapping> <servlet-name>zkLoader</servlet-name>

Servlets HTTP 404 Servlet

I'm trying to send a file with Servlet 3.0/JSP (IDE : Eclipse) Here my JSP code : <form method="post" action="UploadServlet" enctype="multipart/form-data"> Select file to upload: <input type="file" name="file" size="60" /><br /> <br /> <input type="submit" value="Upload" /> </form> And my Servlet : @WebServlet @MultipartConfig(fileSizeThreshold = 1024 * 1024 * 2, maxFileSize = 1024 * 1024 * 10, maxRequestSize = 1024 * 1024 * 50) public class U

Servlets Can there be more than one servlet in a web project?

I am in the middle of creating a course registration system. First, the user fills out a registration form and the user information is then stored in a DB. Then the user is sent to a login page. All of this is taken care of in a file named RegServlet.java. On the next page, the user needs to enter the username and password in order to "log in" to see the list of courses offered. Do I need to create another Servlet file? Tried to add another servlet to the web.xml file but had no luck. Thanks

Servlets set database pulled application constants on startup

I have a lot of dropdown menus in my application. The contents of these dropdown menus is read from the database. Currently, to avoid pulling these values back every-time I want to use them, I pull them back once when I first need them and store them in the session after that. This is not good. I do want to be storing them in the session as there are a number of them, and I think it's a bit, well, clunky. I would like to ideally (assuming you don't disagree), store these 'constants' (they are

Servlets Servlet isn't loaded at startup

I am trying to initial some classes via a SIP-servlet. For that I am using a sip.xml for my mss-2.0.0.FINAL-jboss-as-7.1.2 server. Sip.xml: <?xml version="1.0" encoding="UTF-8"?> <sip-app xmlns="http://www.jcp.org/xml/ns/sipservlet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jcp.org/xml/ns/sipservlet" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.1"> &

Servlets Why is ACK message routed internally after adding Record-Route header to initial INVITE SIP message?

Record-Route header is added to initial INVITE message shown as below. Upon receiving 200 OK for this request, ACK is created by using createAck() method in SipServletResponse class. Output of ACK message is also shown as below. As you see, 47.168.150.15 is added to route header which is initially added to INVITE as Record-Route. Because of that ACK message is routed internally and it is not sent out to 47.168.22.204. Below line is from mobicents debug logs. [org.mobicents.servlet.sip.messag

Servlets How to check if a checkbox is checked

i have checkbox on the form <input class="addToFavorite" type="checkbox" name="addToFavorite"> Add to favorite now when form posting i check if this checkbox checked with this code. But it return true every time. how i can check if checkbox has been really checked? boolean wantAddToFavorites = false; if (isPayAction) { wantAddToFavorites = request.getParameter("addToFavorite").equals("on"); } FireB

Servlets Redirection in Servlet causing erroneous loading of remote resources

I'm developing a Java EE application using web services to communicate with distant server. To avoid Cross-origin resource sharing(CORS) problems I use a bridge Servlet to redirect and filter the requests. However, when some distant pages are loaded the CSS and Javascript files located at this distant server will get their absolute path transformed and their root folder becomes the root of the local Web Application. This is a chunk of HTML code of a distant web page called by the web application

Servlets request.getParameter("xyz") always returns null in POST method - tomcat 7

I just upgraded my servlet container apache tomcat from version 6 to 7. My application breaks after the server is started as request.getParameter("xyz") always returns null and my code won't proceed if it encounters null parameter. It was working fine with apache-tomcat-6.0.33. No other changes was made in the application(mappings and all are done). Also the application was deployed in the newer tomcat version, in the application environment(not in local machine or eclipse). Note:- We have an

Servlets Form validation with EL and JSTL in a JSP page

i am new to coding and follow a training for this, what i am trying to do is, create some radio buttons like this <c:when test="${vraag.vraagtype == 1}"> <p>${vraag.vraagnummer}. ${vraag.tekst}</p> <div class="antwoorden"><p> <c:forEach items="${vraag.alternatieven}" var="alt"> <input type="radio" name="ant${vraag.vraagnummer}" ${requestScope.ant[vraag.vraagnummer] == 'alt' ? 'checked="checked"' : ''} value="${alt}" />${

Servlets Servlet redirection issue

I am having the dropdown list on html page. On submitting the form, i need to pass the value to servlet. When i select red color from dropdown While submitting the form url is framed as, http://localhost:8080/sampleapp/%E2%80%9Dcolor.do%E2%80%9D?%94lb%94=%941%94 Expected url http://localhost:8080/sampleapp/color.do?color=1 Html and web.xml entry is shown below. Can someone find the fix for this issue? home.html <form action=”colors.do” method=”post”> Select the colors <p&g

Servlets Java Application Runs on Production, but not on Local Weblogic Server

For security/privacy issues, the application name has been replaced with ~application~; there are 5 projects within the application: the first project name has been replaced with ~project1~, all other project names have stayed unchanged, Model, RM-Model, ViewController, and WebServices. File location username has been replaced with ~user~. Packages and maps have been replaced with ~package~.~map~; credential name has been replaced with ~credential~; and webapp name has been replaced with ~webapp

Servlets When exactly are the files transmitted to the server?

If I have a servlet that handles file uploads, when does the server actually receive the files? Are they already available when I invoke HttpServletRequest::getParts or will the individual files only be fetched when I actually call the corresponding Part::write? Asked differently, is it my servlet's responsibility to implement a parallel upstream of all files or do I just need to worry about writing them all to disk?

Servlets URL-Redirecting on host_name in browser in tomcat9 using classes/project/servlet

I would like to redirect to particular servlet doGet() when hostname.com hits in browser. I have been going around in this basic issue. Please guide. I have a folder structure of my legacy application in windows environment: D:\tomcat9\webapps\root\web-inf\classes\ProjectName\SRC\SomeFolder. This SomeFolder has a list of servlets. What I Did: tried to replaced index.jsp in ROOT folder with response.SendRedirect("/servlet-url-mapping-path"); tried to add extra hosts in server.xml which de

Servlets JSF set a request attribute before downloading a file through a link

I am using PrimeFaces 7 and must provide a URL link that, when clicked, triggers the download of a .zip file. Currently my component looks like this: <h:outputLink styleClass="zip-download-Link" value="#{request.contextPath}/ave/download?file=Zip&amp;folder=Empty&amp;aveId=#{verlaufBean.existingAveForVerlauf.id}" download="Kaufanbots.zip"> <h:outputText value="Download file"/> </h:outputLink> The .zip file is delivered by a S

Servlets Call to EJB method from a remote jboss server(servlet)

case 1: I'm having war in one jboss server and ejb jar in another jboss server. I want to call my ejb from my servlet which is present in another server. How to call it. can any one help me with a working sample and required configurations. case 2: Message Driven Bean(MDB) in my transaction jboss server and business method in another jboss server. How to call my business method from my transaction server. kindly help me to solve this case Thanks in advance

Servlets How can i redirect to a one servlet from a two jsp page?

how to redirect from one servlet to another two jsp file try { HttpSession session =request.getSession(); session.setAttribute("phonevalues", modal); response.sendRedirect("newdis.jsp"); response.sendRedirect("discondis.jsp"); response.sendRedirect("redisp.jsp"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); }

Servlets Confused with load-on-startup value

When we mention any servlet as loadOnStartup in web.xml then its init method is called at applicaton startup. <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_3_0.xsd     version="3.0">        <servlet>          <servlet-name>SimpleServlet</servlet-name>          <servlet-class>

Servlets Adding response header after doFilter

i have searched and seen couple of post for this problem, but did not find the answer how it is possible. what i want to do is add the header after the filter chain, public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse httpResp = (HttpServletResponse) response; try { HttpServletResponseWrapper bufferedResponse = new HttpServletResponseWrapper (httpResp); chain.doFilter(request, bufferedRespon

Servlets java.lang.ClassNotFoundException: com.google.api.client.http.HttpTransport

i'm trying to build a java server that when it is getting a "POST", it will make a div and inside will be a list of files i got in my google drive. first, i built the google drive side, and got it to a arrylist. and it's working, when i give the right parameters. but when i'm trying to combine it with my server, it's going crazy. my doPost method is invoking this list and wants to print it, but then i have some bad errors. plz advise. Connection.java (removed the id and sec) package javaS

  1    2   3   4   5   6  ... 下一页 最后一页 共 9 页