Java Servlet :: Prevent Cross Site Script In URL
Jan 12, 2015If some one add script in my URL, I want the script not pop up, we have tomcat 6 [URL] .....
View RepliesIf some one add script in my URL, I want the script not pop up, we have tomcat 6 [URL] .....
View RepliesI need fixing an issue in the search textbox in one of the jsp's. I was informed that cross site scripting can be done in the textbox and I kept the below code in my jsp to fix the issue:
Java Code:
searchTerm = request.getParameter("search");
searchTerm = searchTerm.replaceAll("<", "<").replaceAll(">", ">");
searchTerm = searchTerm.replaceAll("[^A-Za-z0-9 ]", "");
searchTerm = searchTerm.replaceAll("eval((.*))", "");
searchTerm = searchTerm.replaceAll("["'][s]*((?i)javascript):(.*)["']", """");
[Code] ....
Now, after applying the above code, the cross site scripting can be done and the problem is that the search can't be done using the textbox and all the time will display none results.
fixing an issue in the search textbox in one of the jsp's. I was informed that cross site scripting can be done in the textbox and I kept the below code in my jsp to fix the issue:
searchTerm = request.getParameter("search");
searchTerm = searchTerm.replaceAll("<", "<").replaceAll(">", ">");
searchTerm = searchTerm.replaceAll("[^A-Za-z0-9 ]", "");
searchTerm = searchTerm.replaceAll("eval((.*))", "");
searchTerm = searchTerm.replaceAll("["'][s]*((?i)javascript):(.*)["']", """");
[code]...
Now, after applying the above code, the cross site scripting can be done and the problem is that the search can't be done using the textbox and all the time will display none results.
Whenever i see online ticket booking site one question arise, How ticket booked in one site reflect in other site.
If i book 2 ticket from PVR online portal that two ticket will be showed as booked in bookmyshow.com, which technology is used for this and how.
I have tried running the java application without adding the site to site list in java security tab. But I get a sand box message as APPLICATION BLOCKED BY SECURITY SETTINGS. How to run the java application without adding the site to site list in java security tab.
View Replies View RelatedI am a beginner want to compile servlet with following path
javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java
Problem arises as follows:
javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options
Is there a way to find how many users are logging on to my site at a specific time?
View Replies View RelatedI am running a page that launches a Java Webstart app and a Java Applet. I don't have problem launching this page in Firefox, but I have to run it in IE11. The thing is IE11 keep redirecting me to oracle java download site. I have install Java RE like 3 times from IE already. What am I missing?
View Replies View RelatedHow can we prevent SQL Injection in Java Code?..is there any Special cases..
View Replies View RelatedI just want to ask about a kind inheritance.Let say I have an interface MachineCode.I also have different classes, Binary, Hex and Octal that implements MachineCode
Question: How can I prevent java to create an Object like this:
Binary bin = new Binary();
Hex hex = new Hex();
Octal octal = new Octal();
those declaration above must be compile error,
I want to create Objects of Binary, Hex, and Octal this way:
MachineCode bin = new Binary();
MachineCode hex = new Hex();
MachineCode octal = new Octal();
When I am watching scjp mock test, I am getting error about security.
I am trying to add www.javaranch.com to site exception list in java control panel. I can see security tab in java control panel, there I find field for Site Exception List. When I am add [URL] .... to this site exception list, list is not getting populated.
Why is that ? Why am I unable to add this site to list ?
I am using 64-bit system and have downloaded and installed 64 bit update patch 51.
The program I'm supposed to create generates a random number between one to ten. Then the program is to ask me if I wish to cross the road. If you choose to cross, the outcomes for 0-2 are "You crossed safely." For 3-5, 75% of the time it should say "RIP you got run over", and 35% of the time it should say "You crossed the street." For 6-8, 60% of the time it should say you made it.", and 40% of the time it should say "You died". For 9-10, it should say "RIP".
So far I have gotten the random number generation part working. I have up to here:
import java.util.Random;
public class test4 {
public static void main(String[] args) {
Random random = new Random();
for(int i =0; i < 1; i++){
int num = random.nextInt(10) + 1;
System.out.println("The number of cars on the street are: " + num + "Do you wish to cross the road?");
}
}
}
I need to create a diagonal cross however I can not figure out how to do the upper left side of it.
Currently I am getting
0*
1--*
2---*
3 *--*
4*-----*
I want to get it to look like
0*------*
1 *--*
2----*
3 *---*
4*------ *
( I replaced spaces with -) So far I have
System.out.println("Input a size(must be larger than 1: )");
size=input.nextInt();
if (size>1) {
for (x=0;x<size;x++){
System.out.println("");
[Code] ....
The program I'm supposed to create generates a random number between one to ten. Then the program is to ask me if I wish to cross the road.
If you choose to cross, the outcomes for 0-2 are "You crossed safely."
For 3-5, 75% of the time it should say "RIP you got run over", and 35% of the time it should say "You crossed the street."
For 6-8, 60% of the time it should say you made it.", and 40% of the time it should say "You died". For 9-10, it should say "RIP".
So far I have gotten the random number generation part working,
import java.util.Random;
public class test4 {
public static void main(String[] args) {
Random random = new Random();
for(int i =0; i < 1; i++){
int num = random.nextInt(10) + 1;
System.out.println("The number of cars on the street are: " + num + "
Do you wish to cross the road?");
}
}
}
I have to calculate auto and cross-correlation from a file, like this:
Rxx(n)= 1/N* SUM[from k=1 to N-n]((x(k)-x(mean))*x(k+n)-x(mean))
and after
Rxy(n)= 1/N* SUM[from k=1 to N-n]((x(k)-x(mean))*y(k+n)-y(mean))
I've 600 x an y,
k = the numbers of x (N is the last one)
n = 0....N-1
I have to calculate auto and cross-correlation from a file, like this:
Rxx(n)= 1/N* SUM[from k=1 to N-n]((x(k)-x(mean))*x(k+n)-x(mean))
and after
Rxy(n)= 1/N* SUM[from k=1 to N-n]((x(k)-x(mean))*y(k+n)-y(mean))
I've 600 x an y,
k = the numbers of x (N is the last one)
n = 0....N-1
already calculated mean, and I've tried the following (but it doesnt work):
String sor;
int i=0;
while ((sor = br.readLine()) != null) {
String [] adatok =sor.trim().split(",");
[Code] ....
So the user is on a website and I want them to go to another site using the same browser and tab.Can this be done in java? And yes the java program is running on the browser .
View Replies View RelatedI made a small aplication which draws 3 rectangles in different spots(0,0 , 50,50 , 100,100)
Am I used an KeyListener + ActionListener, to make them move in the let's call it box.
How can I do in order that those 3 elements do not cross, so you can always see them, they don't collapse into each other?
Java Code:
package matrixmoveelements;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
[Code] ......
the prime numbers from 1 to 2500 can be obtained as follows. From a list of the numbers of 1 to 2500,cross out al multiples of 2 (but not 2 itself). Then, find the next number (n, say) that is not crossed out and cross out all multiples of n (but not including n).
Repeat this last step provided that n has not exceeded 50 (the square root of 2500). The numbers remaining in the list (except 1) are prime. Write a program which uses this method to print all primes from 1 to 2500. Store your output in a file called primes.out.
I have an ecommerce site that has about 100000 SKUs. What is the best practice for handling all the product images as far as where to store them and how to display them on the pages? Should I have a separate HTTP server to serve the images?
View Replies View RelatedModify the program in Assign4 to synchronize access to the instance variable, balance. Save the program as SyncBank.java. Because balance is a double and not an object, it cannot be used as the monitor. Use synchronized methods or synchronized blocks of code as appropriate. Simultaneously test two threads as was done in Assign4. Because the threads can complete too quickly to determine if they are interfering with each other, delay the adding of a deposit by inserting the following code within the synchronized block or method:
try {
Thread.currentThread().sleep(10000); //sleep for milliseconds
}
catch(InterruptedException e) {
}
My code attempt so far:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.text.DecimalFormat;
public class SyncBank extends HttpServlet //throws ServletException, IOException
[Code] .....
I am absolutely new to Java. I am creating a Servlet and getting the error interface is expected here.
I am using IntelliJ 14.
My Servlet code is as follows:-
package ERPdetector;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class ErpServlet implements HttpServlet {
[Code] ....
Using Eclipse I have imported a WAR with source. I have exported that project as a new war and it ran fine. I then added my own package and exported the war again. The jar file does not show up in /WEB-INF/lib folder. When I deploy the war on a tomcat server it barfs the following error:
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.sharpline.fields.form.fields.TextAreaFormType] for bean with name 'com.sharpline.fields.form.fields.TextAreaFormType#53c37' defined in ServletContext resource [WEB-INF/activiti-standalone-context.xml]; nested exception is java.lang.ClassNotFoundException:
[Code] .....
It looks to me like my class (jar) is missing in the final war. How do I resolve this?
Actually I am working on java ee6 web application i tried to set value and max age for the cookie...but I was unable to set maxage what ever the max age value i give .it shows as -1.but my browser accepts and stores cookie.
<i>
"
Cookie sa=new Cookie("ssample", "welcome");
sa.setMaxAge(120);
response.addCookie(sa);
"</i>
using HttpServlet methods. What I want to do is to delay an HttpServletResponse. I set up some response.setHeader but then I want to wait a while after setting other values as the length of data to send and the content itself.
I tried to do that in 2 ways:
1. by using Thread.sleep() - in this case even with sleep of 100 ms the response seems to be lost.
2. by response.wait(TIME) - in this case it will never reach the block after wait, whatever TIME value I use.
I'm looking for a way to gather data from a site page. all data is shown in the same page... I am trying to get the content and parse it is a bit crazy as data seems to be not organized. Itried to get it as a document but still looks crazy.
As all data is shown very clearly in the page (I would like every row to be an object) I'm sure there is some way to collect this data easily. (the data is from this page: [URL] ....)
I'll attach a snapshot and the content I got from the website.
in-play.jpgall_in-play_page.txtin-play.jpgall_in-play_page.txt