JSP :: How To Set Scripting-invalid True

May 12, 2014

I was trying to set scripting-invalid true , but even after setting it to true I am able to use scripting. This is the web.xml under WEB-INF

<web-app>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>
true
</scripting-invalid>
</jsp-property-group>
</jsp-config>
</web-app>

And This is the jsp page

<html>
<body>
<!-- Here I am going to use scripting like scriptlet,expression and other element like jsp declaration element -->
<%!int i=0;%>
<%System.out.println("Scriptlet");%>
<%=new String("Expression")%>
</body>
</html>

Why its not working ?

View Replies


ADVERTISEMENT

Cross-site Scripting (XSS) In Search Box

Aug 13, 2014

I 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.

View Replies View Related

Fixing Cross-site Scripting In Search Box

Aug 13, 2014

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.

View Replies View Related

JCheckBox Is True With Some Value

Jul 30, 2014

I have 3 classes

ARCHIVIO that contain List<Persona>
PERSONA that contatin List<SmartCard> and get/set ORGANIZZAZIONE
ORGANIZZAZIONE

I am looking for a way in java for give me back in a table with checkbox if a PERSONA getOrganizzazione (this is also null value)

public Object getValueAt(int rowIndex, int columnIndex) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
if(columnIndex == 0) {
return ?????????????
}
return null;

[Code] ....

View Replies View Related

True And False / Scanner

Jul 7, 2014

My goal is to ask them for their name and if they got it right then it says yes while if they wrote it wrong, it would say no.

Java Code: public static void main(String[] args) {
Scanner name = new Scanner(System.in);
System.out.println("What is your name?");
String sname = name.nextLine();
name.close();
System.out.println("Are you sure it's " + sname + "?");
Scanner tfname = new Scanner(System.in);
String stfname = tfname.next();

[code]....

View Replies View Related

IF Statement Never Gets Evaluated To True

Oct 27, 2014

Currently experiencing this issue where my IF statement never gets evaluated to 'true'.

public static void search(SalesEmployee[] employeeArray, int searchID)
{
for(int i = 0; i < employeeArray.length; i++) {
String e = ("" + employeeArray[i].getId());
if(e.equals(searchID)) {
System.out.println(employeeArray[i].toString());
}
}
}//end of search

View Replies View Related

Paint Not Looping Until Boolean Is True

Jan 19, 2015

I have a piece of code for an applet that I want to run as the main applet code, and I want it to loop until a boolean is true, but it needs to paint while the code is looping. Here is the relevant part of my code ....

public void paint(Graphics g)
{
g.drawImage(background, 0, 0, this);
if(over == false)
{
tick();

[Code] ....

(I have tried replacing the if with a for, that does not work.)

View Replies View Related

Nested If Statement - Execute If True

Feb 16, 2015

I have a problem with an if statement I've done. I'm not sure how to fix my problem. I'll post the code of the if statement and the output.

if (box = true &&(shippingSwitch ==1))

if (ounces < .5)
{
additionalPrice = ((ounces % .5)/(0.0625))*1.25;
shippingPrice = 15.75 + additionalPrice;//((weight / 8)+ (weight % 8));

[Code] ....

Here's the output I get using println to test it.

Please enter 1 if your package is a letter and 2 if your package is a box
2
Please enter weight in pounds (Example: 1.2):
1.2
Please enter your shipping service option:
Press 1 for Next Day Priority:
Press 2 for Next Day Standard:
Press 3 for Two Day Shipping:
1
7.00

If I comment out the else statement on the last line of code I get the following output:

Please enter 1 if your package is a letter and 2 if your package is a box
2
Please enter weight in pounds (Example: 1.2):
1.2
Please enter your shipping service option:
Press 1 for Next Day Priority:
Press 2 for Next Day Standard:
Press 3 for Two Day Shipping:
1
13.75

What I want to happen is the code under the first comment to to execute if true, or go to the code under the next comments and execute if that statement is true and if that is not true I want the last block of code to execute underneath the last comments.

View Replies View Related

Boolean Value (true Or False) Randomly Set?

Jun 15, 2014

I have the code and it works very well, but my professor wants us to use Junit testing to test our code. I've never used JUnit before, how it works. Is it possible to have a boolean value (true or false) randomly set?

Here is the code I need to test:

package musicalinstruments;
class MusicalInstrument {
public String name;
public boolean isPlaying;
public boolean isTuned;
public MusicalInstrument(){
isPlaying = false;
isTuned = false;

[Code]...

View Replies View Related

How To Return Alert True If Server Is Functioning Normally

Apr 29, 2014

So, I don't know how to start off this program. I'm not looking for the final answer, but I don't know two things: 1. the objective, 2. what type of thing do I start it off with? A method? I'm pretty sure it's not a class right because it already has a class?

public class WebFarm
{
private ArrayList<Server> servers;
/* constructors and other methods and instance variables not shown */
}
 public class Server

[Code] ....

the Instructions:

The ping() method of the Server class returns true if the server is currently functioning normally; otherwise it returns false. Write a definition for the needsAttention() method of WebFarm that returns an ArrayList containing the servers that are not functioning normally:
 
public ArrayList<Server> needsAttention()
{
//I can put code here
}

View Replies View Related

User Input True False Questions

Jan 11, 2015

Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture. When the user selects the correct answer, a message of positive reinforcement should be displayed. If the user selects the incorrect answer, the correct answer should be displayed with a message of constructive criticism. At the end of the quiz, display the number of correct and incorrect answers as well as the percentage of correct responses for each user.

import java.util.Scanner;
class HorticultureQuiz { 
public static void main(String[] args){

[Code].....

View Replies View Related

Truth Table - Display 1s And 0s Instead Of True False

Feb 26, 2005

I'm supposed to take this truth table and alter it so it displays 1's and 0's instead of true false. I'm assumed to do this I would just need to change the variable type and replace true and false with 1 and 0 but every way I try this does not work.

//a truth table for the logical operators.

class LogicalOpTable {
public static void main(String args[]) {
boolean p, q;
System.out.println("P Q AND OR XOR NOT");
p = true; q = true;
System.out.print(p + " " + q +" ");

[Code] ....

View Replies View Related

2D Boolean Array - Gain A Value When All Elements Have Been Turned True

Feb 2, 2014

I'm creating a 4x4 2D array. I need to be notified, or gain a value when all elements have been turned true. Is this as simple as

"If the2DArray[] = true { blah blah }" ?

View Replies View Related

How To Make Panels Visibility Go False / True With Actionlistener

Jan 28, 2014

I'm trying to create a program that has two labels... one in the top left and one in the top right... so far when i run it only the one in the top right (label2) shows... also In the program there will be multiple button and when I click a button it will show a different panel and then i can go back to the first panel to select other panels... so far i haven't figured out how to make panels visibility go false/true with actionlistener. last thing... when i have more then one panel added to the frame none of them show up.

Java Code:

//Matthew
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test{
public static void main(String[] args){

[code]...

View Replies View Related

Return True If Array Contains 3 Adjacent Scores That Differ From Each Other

Mar 12, 2014

Assignment: Given an array of scores sorted in increasing order, return true if the array contains 3 adjacent scores that differ from each other by at most 2, such as with {3, 4, 5} or {3, 5, 5}.

scoresClump({3, 4, 5}) → true
scoresClump({3, 4, 6}) → false
scoresClump({1, 3, 5, 5}) → true

Codingbat AP-1 3rd question

public boolean scoresClump(int[] scores) { 
for (int i = 0; i < scores.length; i++) {
int a = scores[i];
int b = scores[i + 1];
int c = scores[i + 2];
if (Math.abs(b-a) + Math.abs (c-b) <=2)
return true;
}
return false;
}

I got it right for some of the input, but not one of them. I tried to use the for loop and if statement on a specific input that I got wrong:

{4, 5, 8}
scores[1] - scores[0] = 1
scores[2] - scores[1] = 3

I suspect it has something to do with the for loop, but I don't see the problem with it. It should work, shouldn't it?
But anyway, here is the error for {4,5,8} :

Exception:java.lang.ArrayIndexOutOfBoundsException : 3 (line number:7)

View Replies View Related

Statement Block When While Expression Resolves To True Is Never Executed

May 8, 2014

The statement block when the while expression resolves to true is never executed, no matter what i type in:

String option="hit";
String option2="stay";
String choice = null;
int yTotal = 0;

[Code] .....

View Replies View Related

True / False Result Cannot Be Printed Due To Variable Answer

Jun 30, 2014

Code in the book is written exactly like this:

import java.util.Scanner;
public class AdditionQuiz {
public static void main (String[] args){

//Generate random two integers using utility System.currentTimeMillis
int n1 = (int)(System.currentTimeMillis() % 10);
int n2 = (int)(System.currentTimeMillis() / 7 % 10);

[Code] ....

however the true/false result can not be printed due to the "answer" variable...

View Replies View Related

Swing/AWT/SWT :: How To Set Visible Of JScrollPane And JTable To True When Clicking A Button

Feb 13, 2015

In my code where the Button Action Performed is created, I have done the following to ensure that the visibility of the JTable and JScrollPane have been set to true. But it does not work?

Code below:

private void RunQueryButtonActionPerformed(java.awt.event.ActionEvent evt) {
jScrollPane2.setVisible(true);
table_001.setVisible(true);
try {
PreparedStatement st =conn.prepareStatement(SQLTextEditor.getText());
ResultSet rs = st.executeQuery();
table_001.setModel(DbUtils.resultSetToTableModel(rs));
table_001.setAutoResizeMode(table_001.AUTO_RESIZE_OFF);

[code]....

View Replies View Related

Static Method - Take Three Boolean Inputs And Returns True If Odd Number

Jun 28, 2014

Write a static method odd() that takes three boolean inputs and returns true if an odd number of inputs are true, and false otherwise.

View Replies View Related

Array Of Scores - Return True If Each Score Is Equal Or Greater Than One Before

Mar 8, 2014

Given an array of scores, return true if each score is equal or greater than the one before. The array will be length 2 or more.

scoresIncreasing({1, 3, 4}) → true
scoresIncreasing({1, 3, 2}) → false
scoresIncreasing({1, 1, 4}) → true

Java Code:

public boolean scoresIncreasing(int[] scores)
{
for (int i = 0; i< scores.length-1; i++) {
if (scores[i] < scores[i+1] || scores[i] == scores [i+1]) {
return true;
} else {
return false;
}
}
return false;
}

Unsure what the problem is, it will always return True for some reason...

View Replies View Related

Exists Method Always Read True Even If File Doesn't Exist

Nov 20, 2014

I am kind of new to programming in java and I am trying to run a first time setup type of thing for my program so I am saving the settings to a file. If the file doesn't exist I want it to run the first time setup but if the file does exist I want it to skip that process. My problem is that .exists() says reads true whether the file is there or is not there.

public static void main(String[] args)throws IOException{
new Window(); //Runs the Window()
PrintWriter writer = new PrintWriter(path);
boolean bool = new File("path.txt").exists();
System.out.println(bool);
if(!new File("path.txt").exists()){

[Code] ....

View Replies View Related

User Input 2 Ints - Output True If One Is In Range Otherwise False

May 14, 2014

How do I make it so that if both numbers are entered between 10 and 20 it will print false?

The assignment: Ask the user to enter 2 ints. Output "true" if one of them is in the range 10 - 20 inclusive, but not both. Otherwise output "false"

12 99 → true
21 20 → true
8 99 → false
15 17 → false

import java.util.Scanner;
 public class Practice {
 public static void main(String[] args) {
 //get user input
Scanner user_input = new Scanner(System.in);
System.out.print("Enter a number: " );

[Code] ....

View Replies View Related

JSP :: Attribute Invalid For Tag According To TLD

May 6, 2014

My project in eclipse..I get the error below when I run MyTagUser.jsp -

HTTP Status 500 - /jsp/MyTagUser.jsp(14,0) Attribute subTitle invalid for tag Header according to TLD
org.apache.jasper.JasperException: /jsp/MyTagUser.jsp(14,0) Attribute subTitle
invalid for tag Header according to TLD
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)...et

[code]...

View Replies View Related

How To Reject Invalid Input

May 1, 2015

I need to reject invalid input and what is best possible way to do so with the given codes:

Class:

import java.awt.Color;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

[Code] .....

View Replies View Related

Invalid Method Declaration

Feb 26, 2015

import java.util.HashSet;
import java.util.ArrayList;
public class Graph
{
double [] [] adj;
graph (double [] [] a)
{
adj= new double [a.length][a.length];
for (int i=0;i<a.length;i++)
for (int j=0;j<a.length;j++)
adj[i][j]=a[i][j];
}

C:UserscDesktopGraph.java:: error: invalid method declaration; return type required
graph (double [] [] a)

View Replies View Related

Java Method - Return True If String Can Be Found As Element Of Array And False Otherwise

Mar 17, 2014

I am new to Java and would like to ask how to do this question specifically:

Code a Java method that accepts a String array and a String. The method should return true if the string can be found as an element of the array and false otherwise. Test your method by calling it from the main method which supplies its two parameters (no user input required). Use an array initialiser list to initialise the array you pass. Test thoroughly.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved