Filters for the servlets
i have used filters for the servlets ...i am getting nullpointer error in the console..since i kept filter and filter is getting servletcontext object..but before servlet is initialized the filter class's doFilter method is called where it is getting servletcontext object which has to be produced only after servlet get initiated. Thats the problem with this filter!! could anyone guide me to solve this problem?
this is my filter class
The Logging Filter
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class LoggingFilter implements Filter {
private FilterConfig filterConfig = null;
public void destroy() {
System.out.println("Filter destroyed");
this.filterConfig = null;
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
System.out.println("doFilter");
// Log user's IP address.
ServletContext servletContext = filterConfig.getServletContext();
servletContext.log(request.getRemoteHost());
chain.doFilter(request, response);
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println("Filter initialized");
this.filterConfig = filterConfig;
here is the servlet class
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class FilteredServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>User Counter</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("IP:" + request.getRemoteHost());
out.println("</BODY>");
out.println("</HTML>");
and the xml file
<filter>
<filter-name>logging filter</filter-name>
<filter-class>LoggingFilter </filter-class>
</filter>
<filter-mapping>
<filter-name>logging filter</filter-name>
<servlet-name>FilteredServlet1</servlet-name>
</filter-mapping>
<servlet>
<servlet-name> FilteredServlet1</servlet-name>
<servlet-class>FilteredServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FilteredServlet1 </servlet-name>
<url-pattern>/FilteredServlet1</url-pattern>
</servlet-mapping>
Hi
The code is ok, can run in tomcate.
You can get servletcontext from FilterConfig director.
When server start will be initalized, servletcontext has builded. So you can get servletConext even thought run method in Filter.init().
Hope can help you
Similar Messages
-
Does RoboHelp 11 have the ability to add filters for the search function?
Does Robohelp 11 have the ability to add filters for the search function?
There's a page on my site about ZoomSearch. You can set up Rh to work with that and have a page with links or buttons that bring up different search options.
See www.grainge.org for RoboHelp and Authoring tips
@petergrainge -
Are there any spam filters for the IPhone?
While there is a brief comment on what sounds like the solution elsewhere in this thread, I've set up a fantastic spam filter system. Here are the details:
1) You'll need a second account with your ISP or workplace. "[email protected]"
2) Mac Mail has a great series of rules, that with some work, can produce a very clean list of real mail, and a very short list of possible "wanted" mail. In my setting, I get more than 150 mail per day, only about 10 are real. We have three accounts, collectively I'll call them "[email protected]"
3) In the rule settings, make the "last rule" to forward all messages (mail does not need you to specify which box) to "[email protected]"
4) Set mail to check your accounts every several minutes, but to not remove mail from the server for a day or more.
This allows me to see each real e-mail ONCE on my desktop, as I need it on my laptop, and when I need it on my iPhone.
The important thing to remember, is to never send any mail from "[email protected]" else it will also start collecting spam on it's own. Conversely, never check the incoming mail from "[email protected]" on your iPhone for fear of inadvertently validating the address and attracting more spam.
Hope that this helps.
Adam
PS--You windoze folks may be out of luck. The Windoze mail clients often cannot recognize mail that they've already downloaded, or be as slick with setting up rules to handle the spam. -
Reg: filters for the perticular vendor..
Hi all,,
I want to put Filters are required to be set up for particular Vendor number (Ex: 14562365). The Filters required are as below.
Message type Segm.type
MATMAS1 E1EMAS1
Can any body please tell me the procedure, how to do...Hi Mahaboob,
you can set filters in Distribution model for the model view you ceated
To Define a filter object:
1) Navigate to the model view/message type that you want to filter, and expand the
tree to show filter groups.
2) Double click on "No filter set", (or "Data filter active", if one exists).
3) Click on Create filter group
4) Select the field that you want to use in the filter.
5) Enter the value to filter by.
6) Save the model.
Following transactions can help u for filtering data:
BD56 - segment level filtering
BD59 - filtering fields
Regards
Vinod
Edited by: Vinod Varyani on Feb 5, 2009 11:41 AM -
Do I need lens filters for the EOS Rebel T3?
Do I need lens filters?
I agree with all the above...
If you shoot a lot of scenics, for example, a Circular Polarizer might be a very handy filter to have. It's useful to deepen the blue of the sky and make white clouds really stand out, to reduce or control reflections off water and glass, to increase color saturation in foliage and other things outdoors on overcast days, even in some portrait situations. It's one of the most useful of all filters, and also one of the most difficult (or impossible) to replicate in post processing softwares. I would encourage a C-Pol (sometimes "CPL") as one of the first and most important filters you might want.
Neutral density filters are handy for long exposure still photographs, such as making flowing water look "creamy". Today's DSLRs just don't have a low enough ISO setting, so ND filters can help in situations where you either want a long exposure or are trying to use a large aperture in stronger light. ND filters are gray all over to reduce the light reaching the sensor, and come in a wide variety of strengths: 1 stop, 3 stop, 6 stop, 10 stop and more.
I do carry UVs to fit all my lenses (well, at least all the ones that can be fitted with a filter). But they are stored in my camera bag until actually needed for protection. I'd install one if out shooting in a sand storm, for example.
If you go looking for Circular Polarizer or any other filter, don't skimp. Get a good quality, multi-coated to make for the best image quality. B+W MRC, Pro and Kaesemann are very good. Hoya HMC, SHMC, HD and HD2 are too. Also Marumi gets high marks (I haven't used them personally). Heliopan, Singh Ray and Lee are some other well respected brands.
I would encourage you to first get the matching lens hoods for all your lenses, though. A hood is great protection for the lens alone... But when using filters, it's even more important to use a hood (to also protect the filter... both from oblique light and from physical bumps).
Alan Myers
San Jose, Calif., USA
"Walk softly and carry a big lens."
GEAR: 5DII, 7D(x2), 50D(x3), some other cameras, various lenses & accessories
FLICKR & PRINTROOM -
Having seperate filters for the table and sparkline
I created a dataset that shows Name, Number of Success and time for a record. the table keeps the number of successes per person for every hour for the last 24 hours. So every unique name has 24 entries in there.
I would like to come up with a table that will only show the name and the latest number of successes for a person; and to the right of the table, a sparkline that shows the trending for that person for the last 24 hours.
I do not want this to be an expandable table to right. Every row will show the data for a single name. No multiple columns for separate timing info.
So far I tried to apply multiple filters to my table but had no luck.
Any ideas is greatly appreciated.
ThanksHi masavran,
According to your description, you have several records group by Name in your report. Now you only want to show the last record of each group and add a line chart for each group. Right?
In this scenario, we can add a row inside of group and show the last record of the group. Then we add a line chart in this row. Set the series group on name, the chart will display the information of current group (Name). Also we need to hide the detail
row in the group so that it will only display the last row for each name. We have tested this case with sample data in our local environment. The design looks like below:
In this sample, we use Hour to show time and we only have data for previous 6 hours. The result looks like below:
If you have any question, please feel free to ask.
Best Regards,
Simon Hou
-
What are the new / correct URLs for the Servlet / Persistence XSD ?
Hi,
the URLs: http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd
Do not work anymore and you constantly get annoying validation errors in all XSD validating IDE's.
What are the new URLs now? I could not find any related document or article in the internet.
Thanks!
Sebastianyou should never rely on remote resources for xml validation. you should always have them locally.
-
Do we need to put the following code in the web-xml for the project to run
Hi^^^,
actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
I know 404 error is generally due to some error in deployment descriptor.
I am going through this tutorial for creating project in eclipse WTP
this says that I need to include the following code in web-xml. Please look at the quotes below
"Web modules in J2EE has a deployment descriptor where you configure the web application and its components. This deployment descriptors is called the web.xml. According to the J2EE specification, it must be located in the WEB-INF folder. web.xml must have definitions for the Servlet and the Servlet URI mapping. Enter the following lines into web.xml:"
"Listing 2. Deployment Descriptor web.xml"
<servlet>
<servlet-name>Snoop Servlet</servlet-name>
<servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Snoop Servlet</servlet-name>
<url-pattern>/snoop/*</url-pattern>
</servlet-mapping>
My question is, it is necessary to include the above lines between <servlet> and </servlet-mapping> in web-xml
thanks and regards,
Prashantpksingh79 wrote:
actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
I know 404 error is generally due to some error in deployment descriptor. what's the url you've put.
<servlet>
<servlet-name>Snoop Servlet</servlet-name>
<servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
</servlet> Every Servlet has to have a <servlet></Servlet> tag in the web.xml
the <servlet-name>is for the naming the servlet and the <servlet-calss>is for class file of the servlet in your case the .class file is to be in the package of tutorial,if it's not then how the container will no where the calss file is
<servlet-mapping>
<servlet-name>Snoop Servlet</servlet-name>
<url-pattern>/snoop/*</url-pattern>
</servlet-mapping>You type something in your url likk http://localhost:8080/webappname (Tomcat server),so for url mapping instead of typing the entire class file name ,you just enough have to type what you've put in the <url-mapping> tag and it has to be inside of <servlet-mapping>
I think the problem is in <url-pattern> change it like /snoop<url-pattern>
My question is, it is necessary to include the above lines between <servlet> and ></servlet->mapping> in web.xmlSo now you think whether you need something inside <servlet>and </servlet-mapping> -
Use jar file for one servlet in one application (not global in classpath)
I have a servlet application that needs a jar file to load with one particular servlet. If I put the classpath to the jar file in the jvm12.conf, the servlet loads fine. I can't run it like that, however, since I use another jar file by the same name in a different application. I would like to specify it only with the servlet that needs it. According to the online help file, it says more than one jar, zip, or class file can be specified in the servlet classpath, but that doesn't seem to be the case. We're running iPlanet 4.1. I've tried adding the classpath to the jar file after the classpath for the servlet itself (servlet.properties), but it gives the class not found error for that function. Is there a way to do this? Context.properties, maybe? I can't find any instructions on setting that up.
You might have better luck asking this question on a web server forum. This is an application server forum and most people here are going to more experienced with iAS.
David -
Problem in retriving the realpath from the servlet
Hai All,
I am facing problem in retriving the realpath from the servlet.
I am using the following code in order to retrieve the path.
String prefix = getServletContext().getRealPath("/WEB-INF/classes");
The value returned from above code is null.
I am using Weblogic 8.1 server, and deploying my servlet as WAR file inside
the weblogic server.
Is this the problem with the weblogic server or with the code. Is there any way to over come this.
I need the path as i am implementing Log4j for the servlet and i have to pass the
configuration file in one of the function "PropertyConfigurator.configure(file);"
where the file should include complete path.
My configuration file is in WEB-INF/Classes directory.
Any help is appreciated.
Thanks in advance
Pooja.String realPath = request.getRealPath(request.getContextPath());
That should return the path up to where you have your servlet context. -
How to create a new variant and a job sheduled to use it for the exisisting programs
Hi
1. The ALV Grid Control is a tool with which you can output non-hierarchical lists in a
standardized format. The list data is displayed as a table on the screen.
The ALV Grid Control offers a range of interactive standard list functions that users need
frequently (find, sort, filter, calculate totals and subtotals, print, print preview, send list,
export list (in different formats), and so on. These functions are implemented in the
proxy object class. You as the programmer have the possibility to turn off functions not
needed. In most cases the implementations of the standard functions provided by the
control are sufficient. However, if required, you can adjust these implementations to
meet application-specific needs.
You can add self-defined functions to the toolbar, if necessary.
The ALV Grid Control allows users to adjust the layout of lists to meet their individual
requirements (for example, they can swap columns, hide columns, set filters for the
data to be displayed, calculate totals, and so on). The settings (list customizing) made
by a specific user are called a display variant. Display variants can be saved on a userspecific
or on a global basis. If such display variants exist for a list, they can be offered
to the user for selection. If a display variant is set as the default variant, the associated
list is always displayed based on the settings of this variant.
2. REUSE_ALV_LIST_DISPLAY
REUSE_ALV_GRID_DISPLAY
REUSE_ALV_FIELDCATALOG_MERGE
REUSE_ALV_COMMENTARY_WRITE
3. Use of Field Catalog is to determines the technical properties & add formating information of the column.
6. all the definition of internal table, structure, constants are declared in a type-pool called SLIS.
7.fieldcat-fieldname
fieldcat-ref_fieldname
fieldcat-tabname
fieldcat-seltext_m
5. Form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The report output can contain up to 90 columns in the display with the wide array of display options.
<b>The commonly used ALV functions used for this purpose are;</b>
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
But either no.7 or No.8 is there in the Program.
<b>
How you call this function in your report?</b>
After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
Then use follwing function module.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Prog.name'
I_STRUCTURE_NAME = 'I_ITAB'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_ITAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
ENDFORM. " GET_FINAL_DATA
The object F_IT_ALV has a field, the activity ACTVT, which can
contain four permitted values: 01, 02, 03 and 70. Each of the
activities 01, 02 and 70 controls the availability of particular
functions (in the menu and the toolbar) of the ALV line item list:
a) 01: "Settings -> Display variant -> Save..."
b) 02: "Settings -> Display variant -> Current..." and
"Settings -> Display variant -> Current header rows "
c) 70: "Settings -> Display variant -> Administration..."
Activity 03 corresponds to the minimum authorization, which is the
most restricted one: The user can only select layouts which have
been configured already. In particular, all of the other functions
named above are inactive with activity 03.
Now if you want to permit a user to change the column selection and
the headers as well as to save the layout thus created, for example,
but if you do not want to permit the user to administrate the
layouts, you grant him or her the authorization for activities 01
and 02.
Check this link it will be mosty usefull for u
http://www.sap-img.com/fu017.htm
Reward all helpfull answers
Regards
Pavan -
Internet Filtering for iPod Touch
I have a 12 year old boy that just got an iPod touch for his birthday. Is there anything anyone can reccomend to filter the internet ie. Net Nanny? Thank you!
Maybe try turning off safari on restrictions and then installing k9 interent browser app, they're a internet filter, the app allows access to the internet with thier standard setting of filtering for the internet browser. Its quite good, its free, however you cant customize what it blocks from being seen when you browse the interent.
https://itunes.apple.com/au/app/k9-web-protection-browser/id407657840?mt=8 -
Hi,
I have set up the following on a solaris 2.8 box
a) A custom application packaged as a jar file...
b) Set up the initial environment for my application using weblogicenv.sh
c) The first request for the servlet is satified, in the sense that I am able
to get some data out from my servlet..
d) The second page posts some variables, which is not being read by my application
and hence I am getting a HTTP:404 (file not found)..
e) I check in the access.log the above error is noticed.
I have read all the documentation realting to the weblogic app server properties
file...
I believe I am missing out on some rewrite rules in config files...But don't
know which ones..Any ideas/suggestion ...
TIA
Praveenhai,,,
u didnt mention which web server u r using... -
Different url-patterns for same servlet running in 2 different environments
Hi All,
I have a question about url mappings in my web.xml file and I hope somebody can help. The situation is that I�m putting together a web app using a combination of JSPs and servlets. I can�t develop on the machine that it will be hosted on, so I�m working and testing on my own machine and will transfer to the host machine when finished. However, the host machine is set up to map serlvets to http://�/servlet/MyServlet but the copy of tomcat I have installed locally maps to http://�/MySerlvet. My question is, when I get ready to transfer my application do I have to go through all my code and find serlvet references and insert the �servlet/� path info required by the hosting service, or can I just change the url patterns for the servlet mappings of the web.xml file on the host machine ? In other words:
Local install of Tomcat where servlets are accessed at http://�/MyServlet
<servlet-mapping>
<servlet-name> MyServlet </servlet-name>
<url-pattern>/MyServlet </url-pattern>
</servlet-mapping>
Host machine install of Tomcat where servlets are accessed at http://�/servlet/MyServlet
<servlet-mapping>
<servlet-name> MyServlet </servlet-name>
<url-pattern>/servlet/MyServlet </url-pattern>
</servlet-mapping>
I guess my thinking is that it would be better/easier to have a remote and local version of the web.xml file that reflects the environment each one resides in and have only one codebase rather than 2 codebases and 1 web.xml file. Am I thinking about this in the right way, or have I misunderstood something?
Thanks,
PeterWhat you�re suggesting is logical, but won�t that
effect all the other stuff I�ve got running on my
local Tomcat install that expects servlets to be
accessed at http://.../ServletName ?
in web.xml, you decide of your mapping, so you could use the /servlet/ServletName pattern for your application that needs to be remote, and /ServletName for the rest of your stuff. You can even define more than one mapping for a servlet...
In fact, you should probably put your whole application that is going to be on a remote server in it's own context, and to be ahead of dufymo :-) , learn to put it a war file for deployment. -
Filtering Setup-Table and same filtering for Delta-Queue needed
Dear All,
I'm looking for the best solution to do the filtering for the delta-queue.
In program RMCVNEUA I'm filtering (excluding specific SalesOrg) data for the setup-table creation. I'm loading these data to the BW system.
BUT now my issue is, that with the delta-queue I'm getting also data for the SalesOrg I have excluded in the setup-table, as I have no filter for the delta-queue.
My Question: Where/How to filter by the same criteria the entries for the delta-queue?
Thanks for your support,
Peggy
some more details: Application 11; Queue-Name MCEX11; using 2LIS_11_VAHDR, 2LIS_11_VASTH, 2LIS_11_VAITM, 2LIS_11_V_SSLDear Arvind,
if there is no way in R/3 the solution must be in BW, but how exactly should that look like in the best/smartest way?
Let us look in detail at an Example:
DSO 0SD_O03 is getting data from 2LIS_11_VAHDR and 2LIS_11_VASTH.
1) For VAHDR I have the chance to delete not needed VKORG already in the InfoPackage, or load first to PSA and than filter in DTP or delete in Startroutine in Transformation.
2) BUT for VASTH, which has no VKORG information at all, I'm only able to delete the Dataset after it's loaded/activated in the DSO, as the rubbish-Dataset won't have any 0SALESORG. How to do that?
Thx,
Peggy
Maybe you are looking for
-
This weekend I changed over from my HP-G60 which ran on Vista with Firefox 3.6.1 and my connection to Peirce College in Philadelphia was recognized and supported. They do not, as yet, support the 4.0 version. I downloaded your 4.0 this morning onto m
-
Doc error in OrderBook Tutorial
At the end of the chapter for fault handling it says in the summary: Reviewed the credit rating results returned from the Credit Rating service to the client. The invalid social security card number that you entered invoked the fault handling and exc
-
I recently installed Mountain Lion, now my printer/fax/scanner is useless. If anyone has been able to fully use an HP Officejet J4680 please let me know how to get it to work, I am strongly considering on restoring my iMac to Snow Leopard where I can
-
after I launch the WorkBench (version 9.5), log in, launch the Form Designer for the first time, it always shows me the "PDF Structure" tab (along with the "Hierarchy", "Data View" and "Tab Order"). I can't get rid of it. I can close it by clicking t
-
Acrobat Pro XI Not installing.
I am running Windows 7 64Bit and I downloaded Acrobat Pro XI three times through the Acrobat Assistant and every time I get the following message. This version of the file is not compatible with the version of windows you are running. Request you to