How To Avoid Hardcoded Href URL In JSP
Feb 12, 2014How to avoid hard coded href url .
For example a href="www.yahoo.com">
How to avoid hard coded href url .
For example a href="www.yahoo.com">
my code uploads a file to server.it works perfectly. however when i try to access it through href it says file not available.but the file is present.
Also,if i make any changes to the file like renaming tit etc the link works. My code is
<tr valign="center"><div align="left">
<td align="left"><B><font size="2" color="#4d5075"> File Already Uploaded</font></B></td>
<td><a href="cml/coml_upld/mfile_upload/Flashcard.pdf" >Click Here to view Uploaded BBU</a>
</td>
</tr>
my file upload code is
<%@ page import="java.io.*"%>
<%
try {
String saveFile = "";
String saveFile1="";
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
[code]....
I am trying to pass additional information through <a href> tag
<a href="welcome.jsp & param=<%=add.getID()%>">Welcome </a>
The error is : HTTP Status 404 - /WebApp/welcome.jsp & param=6
The id obtained from add.getID() is displayed in address bar on the browser.
I want to use this id on the next page. I try to use :
request.getParameter("param");
But could not get the ID....
as there is a button on the website, that I need to click, but it returns a number using javascript that will access the page. Without that number, accessing the page won't work. Therefore, either I need to click the button, or return that data when I access the url. Here is the line in the html.
<a href="/missions.php?jid=11&cat=2&formNonce=49af09362db790 a6b364401c4ea52a08b515df4a&h=284e4fe4946e6fb8af3a6 62f4583454eebc8bd23" class="actionButton" onclick="return fsb11('5494');">Do It</a>
I want show one image when i click on one "href". I have write this code....
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
[Code] ......
I have been playing around with my code, but how to avoid NullPointerexception.. So my program's point is simple, use Jsoup to scrape html of certain webpage, then i search the things i want and print them out. Problem is, when scraped html doesnt contain even 1 thing on my search list, i get NullPointerException... i understand why, Heres part of my code:
Java Code:
//Things i need to search from html
String[] MySearchArray = new String[]{"138","146","474"};
//Search things contained in MySearchArray and print them out
for (String Ml : MySearchArray) {
Element flights = doc.select(String.format("tr:contains(%s)", Ml)).first();
Elements flights2 = flights.select("td");
System.out.println(flights2.get(4).text() + " " + flights2.get(0).text()+ " " + flights2.get(3).text());
} mh_sh_highlight_all('java');
I have a HashMap with multiple values at runtime. In that map one key has empty value , how to avoid this value to add in a list. some code sample is below:
public HashMap getLoop2Map(Map map, String xslFile , int sheetNo){
HashMap hashMap = new HashMap();
try{
ArrayList list = new ArrayList();
System.out.println("-------Map : " +map);
list.add(map.values());
//System.out.println("------- boolean : " +val);
System.out.println("------List : " +list);
}
I do not want to add the empty value in a list ...
result in map
-------Map : {Free Text Entry={},
Mouth / Throat={Free Text Entry={Free Text Entry=<FORMFILENAME>EditChartPhysicalExamText.form
</FORMFILENAME><TAG>"<MUSCULOSKELETAL.PE>"</TAG>},
Salivary Glands Condition={Salivary Glands Condition=MouthAttribute},
Examination Overview- Mouth / Throat={Examination Overview- Mouth / Throat=MouthAttribute},
Tonsils={Tonsils=MouthAttribute},
[Code] ....
I'm struggling with that piece of code, my intention is to check for the object I want to add before adding it, so there won't be any duplicate on my list. I'm not sure how could I do that, since I'm working with objects.
Person is a class with few parameters such as id, name, and few others.
I guess I should search for a person with the same id, since that has be unique, but can't get it right.
private ArrayList<person> model= new ArrayList<>();
//...
if (model.contains(person))throw new IllegalArgumentException("duplicate");
else model.addElement(person);
is it possible to avoid deadlock while coding..
View Replies View RelatedI wanted to make a small program to move a small rectangle by pressing the WASD keys. The program works, except that when I hold a key to move the rectangle, after a second, auto-repeat starts up, and the rectangle motion accelerates. I want to prevent automatic repeat to activate, so that the rectangle moves at a constant speed when I hold a key and stops when I released. Here is the ButtonMotion classe :
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.KeyStroke;
[code]....
how to avoid getting negative numbers of coins, use casting and mod to show how many quarters, dimes, nickels, and pennies there are?
import java.util.Scanner;
public class VM
{
public static void main(String[] args)
{
//money deposit
Scanner input = new Scanner(System.in);
[code]....
I have code which query value from database,the use case is the user can enter value as 1,01,11 in database but when the user enter value in xml file he can only enter 11,01,12 in database there is two columns lets say column test1=1 and test2=2 combination of this is 12,which is the value the use will enter in xml, but sometime the use can enter test1=04 than column test2=00 ....
View Replies View RelatedI'm using EclipseLink, WildFly, EJB, postgresSQL and JSF.I'm trying to persist some countries and their localities.So I've:
- Two entities Countries and Localities in which I specify respective columns and relations.
- Abstract Session beans for entity classes: AbstractFacade providing basic crud methods and entity manager.
- Two concrete session bean for entity classes: CountriesFacade and LocalitiesFacade.
- A JSF managed bean named geoJSF.
- A JSF page with a form allowing to insert new country and localities.
In geoJSF I'm injecting via EJB CountriesFacade as property named cf and LocalitiesFacade as property named lf.For the actual inserting country and locality I'm using geoJSF.country and geoJSF.locality. When the form is submitted I'm simply doing:
this.cf.create(this.country);
this.locality.setCountry(this.country); //<- this throw an exception (unique constraint violation) due to the attempt to reinsert this.country
this.lf.create(this.locality);
I disabled all cascade among relations definitions.Based on what I know this.country should appear detached to entity manager so, setting relation the entity manager try to re-persist it.
Write a program to copy file from c: drive to another drive and avoid duplication??????????
View Replies View RelatedI am trying to call another swing frame from my current frame. And after calling second frame i dispose the current frame.
But while second frame coming on the screen, current frame gets dispose and second frame takes some seconds to appear on screen.
So its creating a bad flickering effect on screen and its not suitable for my application.
I want that first frame will call sencond frame and it will not look like second frame is called. I just want to cancel flickering effect.
Here is my source code.
1st Frame:
public class Welcome extends JFrame {
JFrame f;
JTextArea nameField,nameField1;
JLabel lable;
[Code] .....
The method I am trying to successfully write is startsWith(String s1, String s2)
The intention of the code is to return true if s2 starts with the string s1, and false otherwise. For example,
x.startsWith("Maplestory","Maple"); Should return true.
This code partially works, depending on the values entered into it. When it is supposed to return true, it does do this. When it is meant to return false, I get a StringIndex OutOfBounds Exception.
public class CC02{
String remove1(char c, String s){
String to_return="";
while(true){
if(s.equals(""))
return to_return;
[Code] ....
The method I have written uses one other method from my code, which is "reverse". Any way to return false without getting this error.
I'm writing an IRC server in Java, however when a client tries to connect I get a ConcurrentModificationException trying to add them to an ArrayList. My code is Here: [URL]
I don't understand why I am getting a ConcurrentModificationException or what one is.
I have a practice program (written with NetBeans IDE 7.4) that calls methods to:
(1) fill an array with user input values
(2) sort the array values into ascending order
(3) print the array in assorted order.
(4) print the array without any duplicates
Method (4) prints the contents of the array without printing any duplicates. That is, if a number in the array has already been printed, it will not be printed again.
Method (4) seems to work, but may be inefficient or I may have done too much work making it difficult on myself or making the logic too confusing.
Is there a better way to do this WITHOUT using built-in functions in Java's library?
(Such as writing this method using for loops and counter variables: As practice I am supposed to avoid using Deleting functions for duplicates)
Here is my code:
public static void Duplicates(int [] array){
int duplicates = 1;
String Output = "";
for(int i = 0; i < array.length -1; i++) {
if (array[i] != array[i+1]){
duplicates ++;
[Code] .....
I've already seen large code blocks inside JSP's, in a way it is very hard to maintain the web application. Is there a way to avoid that?
View Replies View RelatedI want to create a ScrollPane where I can scale the contents. Think of a simple drawing program that allows you to zoom in and zoom out.
If I create a ScrollPane in SceneBuilder and then drop a couple of Circles into the AnchorPane all looks good.
If I then set a scale of 0.5 for the AnchorPane Scale X and Scale Y the AnchorPane gets scaled about its centre leaving space between the left and top edge of the AnchorPane and the left and top edge of the enclosing ScrollPane.
The only way to get the AnchorPane so that it aligns with the top left of the ScrollPane seems to be to add a negative amount to Translate X and Translate Y.
In my application I would like the user to be able to adjust the zoom (Scale) continually and also the size of the AnchorPane must be allowed to change as the user add/deletes/edits content.
Does this mean I have to continually monitor the AnchorPane properties and set compensating Translate X and Translate Y values each time? Or is there an easier way to achieve what I want?
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.*?>
<?import javafx.scene.shape.*?>
[Code] ....
We have developed a java application, whose primary objective is to read a file(input file), process it and convert it into set of output files. (I have given a generic description of our solution, to avoid irrelevant details).
This program works perfectly fine when the input file is of 4 GB, with memory settings of -Xms4096m -Xmx16384m in a 32 GB RAM
Now we need to run our application with the input file of size 130 GB.
We used a linux box with 250GB RAM and with memory setting of -Xms40g -Xmx200g (also tried couple of other variations) to run the application and hit OutOfMemory Exception.
At this stage of our project it's very hard to consider redesigning the code to accommodate hadoop ( or someother large scale data processing framework), also the current hardware configuration which we can afford is 250GB of RAM.
Any ways to avoid OutOfMemory Exceptions, what is the general practice when developing these kind of applications.?