How to combine this code
Hi,
I am learning JSP. I made this page which takes up user name and roll and prints it.Can you please show me how to do this in a more better way. Such as instate of 3 page can I combine it into two or any thing that you have in mind...
Thank you very much,
M
Form.html (this gets the user data)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<FORM METHOD="POST" ACTION="SaveName.jsp">
Enter Name:
<input type="text" name="name" value="" size="30" />
Enter Roll:
<input type="text" name="roll" size="30"/>
<input type="SUBMIT"/>
</FORM>
</body>
</html>UserData.java
package newpackage;
public class UserData {
String name;
int roll;
public void setName(String value){
name = value;
public void setRoll(int value){
roll = value;
public String getName(){
return name;
public int getRoll(){
return roll;
}SaveName.jsp
<jsp:useBean id="newpackage" class="newpackage.UserData" scope="session"/>
<jsp:setProperty name="newpackage" property="*"/>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>SaveName.jsp</title>
</head>
<body>
<A HREF="NextPage.jsp">Click here</A>
</body>
</html>NextPage.jsp
<jsp:useBean id="newpackage"class="newpackage.UserData" scope="session"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
Name = <%= newpackage.getName() %>
<br>
Roll = <%= newpackage.getRoll() %>
</body>
</html>
Geesh. Throw that tutorial away. Right now.
Start over at one of those tutorials:
Sun Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc]
Coreservlet.com tutorials: [http://courses.coreservlets.com/Course-Materials/]
I also highly recommend a book of Bates & Sierra: [http://www.amazon.com/Head-First-Servlets-JSP-Certified/dp/0596005407]
Similar Messages
-
How to combine this query so that i can display the ouput together
I have no idea how to combine this query together.Someone please help.I want the ouput to display oni 1 result combining all together.
select facility, route, operation, script_id
from F_ROUTEOPER
where facility = 'A01' and operation in ('6910','7976') AND src_erase_date is null
and (script_id not in ('PHQ-LOTCHKRV','PHQ-LOTCHK') or script_id is null)
AND (route NOT LIKE '9EL%' AND route NOT LIKE '9TB%'AND route NOT LIKE 'BLB%' AND route NOT LIKE 'BWR%' AND route NOT LIKE 'CRL%')
select facility, route, operation, script_id
from F_ROUTEOPER
where facility = 'A01' and operation in ('6912','7976') AND src_erase_date is null
and (script_id not in ('PHQ-LOTCHKRV','PHQ-LOTCHK') or script_id is null)
AND (route NOT LIKE '9EL%' AND route NOT LIKE '9TB%'AND route NOT LIKE 'BLB%' AND route NOT LIKE 'BWR%' AND route NOT LIKE 'CRL%')
select facility, route, operation, script_id
from F_ROUTEOPER
where facility = 'A01' and operation in ('7344','7976') AND src_erase_date is null
and (script_id not in ('PHQ-LOTCHKRV','PHQ-LOTCHK') or script_id is null)
AND (route NOT LIKE '9EL%' AND route NOT LIKE '9TB%'AND route NOT LIKE 'BLB%' AND route NOT LIKE 'BWR%' AND route NOT LIKE 'CRL%')
select facility, route, operation, script_id
from F_ROUTEOPER
where facility = 'A01' and operation in ('8344','7976') AND src_erase_date is null
and (script_id not in ('PHQ-LOTCHKRV','PHQ-LOTCHK') or script_id is null)
AND (route NOT LIKE '9EL%' AND route NOT LIKE '9TB%'AND route NOT LIKE 'BLB%' AND route NOT LIKE 'BWR%' AND route NOT LIKE 'CRL%')
Edited by: 965547 on Nov 5, 2012 12:55 AMThe only difference which i am seeing in your queries is the Operation ('6910', '6912','7344','8344')
Then why don't you put all values in One like this
Select facility, route, operation, script_id
from F_ROUTEOPER
where facility = 'A01' and operation in *('6910', '6912','7344','8344','7976')* AND src_erase_date is null
and (script_id not in ('PHQ-LOTCHKRV','PHQ-LOTCHK') or script_id is null)
AND (route NOT LIKE '9EL%' AND route NOT LIKE '9TB%'AND route NOT LIKE 'BLB%' AND route NOT LIKE 'BWR%' AND route NOT LIKE 'CRL%')
Hope this will resolve your problem.
Oracle-911 -
Anyone knows how to make this code to netbeans??
anyone knows how to make this code to netbeans?? i just want to convert it into netbeans... im not really advance with this software... anyway..just reply if you have any idea...or steps how to build it... etc.... thanks guys...
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.util.regex.*;
public class FilterTable {
public static void main(String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame frame = new JFrame("Sorting JTable");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object rows[][] = {
{"AMZN", "Amazon", 41.28},
{"EBAY", "eBay", 41.57},
{"GOOG", "Google", 388.33},
{"MSFT", "Microsoft", 26.56},
{"NOK", "Nokia Corp", 17.13},
{"ORCL", "Oracle Corp.", 12.52},
{"SUNW", "Sun Microsystems", 3.86},
{"TWX", "Time Warner", 17.66},
{"VOD", "Vodafone Group", 26.02},
{"YHOO", "Yahoo!", 37.69}
Object columns[] = {"Symbol", "Name", "Price"};
TableModel model =
new DefaultTableModel(rows, columns) {
public Class getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())) {
returnValue = getValueAt(0, column).getClass();
} else {
returnValue = Object.class;
return returnValue;
JTable table = new JTable(model);
final TableRowSorter<TableModel> sorter =
new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane pane = new JScrollPane(table);
frame.add(pane, BorderLayout.CENTER);
JPanel panel = new JPanel(new BorderLayout());
JLabel label = new JLabel("Filter");
panel.add(label, BorderLayout.WEST);
final JTextField filterText =
new JTextField("SUN");
panel.add(filterText, BorderLayout.CENTER);
frame.add(panel, BorderLayout.NORTH);
JButton button = new JButton("Filter");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText();
if (text.length() == 0) {
sorter.setRowFilter(null);
} else {
try {
sorter.setRowFilter(
RowFilter.regexFilter(text));
} catch (PatternSyntaxException pse) {
System.err.println("Bad regex pattern");
frame.add(button, BorderLayout.SOUTH);
frame.setSize(300, 250);
frame.setVisible(true);
EventQueue.invokeLater(runner);
}its okay onmosh.....what we need to
this...forum....is to have a good......relationship
of programmers......and to start with .....we need to
have a good attitude........right.....???.....no
matter how good you are in programming but if you did
not posses the right kind of attitude....everything
is useless.....in the first place....all we
want....is just to ask...some....help....but
conflicts......but unluckily......we did not expect
that there are members in here which......not
good...to follow.....just as suggestion for those
people not having the right kind of attidude...why
can't you do in a very nice message sharing in a very
nice....way....why we need to put some
stupid....stuff...words.....can't you live with out
******* ****....its not.....lastly especially you
have your children right now and people around...that
somehow......idiolize...you even me....is one of
them......but showing but attitude....is not
good......tnx....hope you'll take it this....in the
positive side.....be optimistic...guys....the
world..is not yours....all of us will just past
away....always..remember that one.....treasure..our
stay in this....temporary home.....which...is
world....Whoa. That post seems to be killing my brain.
URK
Join........us..........do not be..........afraid....... -
Hello
can someone please tell me how to modify this code so that I dont have to enter the file path at all? When i give the same file path constants to both the read and write VIs I'm getting an error message.
Attachments:
read and write.vi 11 KBYup use the low level File I/O opening the reference once, and closing it once.
As for the path selection you have an unwired input which is the path to use. Programatically set that and you won't be prompted to select a path. Usually this is done with a path constant to a folder, then using the Build Path, to set the file name in that folder.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously. -
How to implement this code in labview?
How do implement this pseudo code in labview? Please keep in mind "a" and "c" in the code below ARE VARIABLES
for i =0 to i=maxvalue
if i <= a
output = output2
else if i > a AND i<=c
output = output2
else if i < c
output = output3
else i = d
output = output4
I understance i can use a case structures and modify the label, but i do not know how to make the label dependent on a variable value.
ThanksTry an array of boudaries and use threshold array. See this old example:
Now just iterate over an array of values using a FOR loop.
LabVIEW Champion . Do more with less code and in less time . -
Inner join with if statement , how to combine these code ?
Hello everyone, I have 2 group of code here. This 2 group of code is working without error. But I face a problem , I need to group up this 2 group of code. Please take a look, thank you This is the first code i create.
SELECT r.Name , r.Restaurant_ID, f.feature, r.Price_Range, r.Cuisine_ID, c.Cuisine,
s.State_ID, s.State, l.Location_ID, l.Area, l.State_ID, r.Name, r.Location_ID
FROM Restaurants r, Bridge1_Restaurant_Features b, Features f, Cuisine c, State s, Location l
where 0=0
AND b.Feature_ID = f.Feature_ID
AND b.Restaurant_ID = r.Restaurant_ID
AND r.Cuisine_ID = c.Cuisine_ID
AND r.Location_ID = l.Location_ID
AND l.State_ID = s.State_ID
<cfif ARGUMENTS.Feature_ID IS NOT "">
AND b.Feature_ID IN (#ARGUMENTS.Feature_ID#)
</cfif>
<cfif ARGUMENTS.Price_Range IS NOT "">
AND r.Price_Range IN (#ARGUMENTS.Price_Range#)
</cfif>
<cfif ARGUMENTS.Cuisine IS NOT "">
AND r.Cuisine_ID = (#ARGUMENTS.Cuisine#)
</cfif>
<cfif val(ARGUMENTS.LocationID2) IS #val(ARGUMENTS.StateID)#>
AND l.State_ID = #val(ARGUMENTS.LocationID2)#
<cfelse>
AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
</cfif>
Then, I notice the feature_ID i need to use another logic to show the result. The code is like this
SELECT r.Restaurant_ID, r.Name, f.Feature
FROM Restaurants r
INNER JOIN Bridge1_Restaurant_Features b ON b.Restaurant_ID = r.Restaurant_ID
INNER JOIN Features f ON b.Feature_ID = f.Feature_ID
INNER JOIN
SELECT Restaurant_ID, COUNT(Feature_ID) AS FeatureCount
FROM Bridge1_Restaurant_Features
<!--- find matching features --->
WHERE Feature_ID IN ( <cfqueryparam value="#ARGUMENTS.Feature_ID#" cfsqltype="cf_sql_integer" list="true"> )
GROUP BY Restaurant_ID
<!--- having ALL of the requested features --->
HAVING COUNT(Feature_ID) = <cfqueryparam value="#listLen(ARGUMENTS.Feature_ID)#" cfsqltype="cf_sql_integer">
) ck ON ck.Restaurant_ID = r.Restaurant_Id
I want combine this 2 group together. The second group have to replace
<cfif ARGUMENTS.Feature_ID IS NOT "">
AND f.Feature_ID IN (#ARGUMENTS.Feature_ID#)
</cfif>
I try few way to group this 2 code, but fail to make it. The code i try is on below, it get error.
SELECT r.Name , r.Restaurant_ID, f.feature, r.Price_Range, r.Cuisine_ID, c.Cuisine,
s.State_ID, s.State, l.Location_ID, l.Area, l.State_ID, r.Location_ID
FROM Restaurants r, Features f, Cuisine c, State s, Location l
INNER JOIN Bridge1_Restaurant_Features b ON b.Restaurant_ID = r.Restaurant_ID
INNER JOIN Features f ON b.Feature_ID = f.Feature_ID
AND r.Cuisine_ID = c.Cuisine_ID
AND r.Location_ID = l.Location_ID
AND l.State_ID = s.State_ID
<cfif ARGUMENTS.Feature_ID IS NOT "">
INNER JOIN
SELECT Restaurant_ID, COUNT(Feature_ID) AS FeatureCount
FROM Bridge1_Restaurant_Features
<!--- find matching features --->
WHERE Feature_ID IN ( <cfqueryparam value="#ARGUMENTS.Feature_ID#" cfsqltype="cf_sql_integer" list="true"> )
GROUP BY Restaurant_ID
<!--- having ALL of the requested features --->
HAVING COUNT(Feature_ID) = <cfqueryparam value="#listLen(ARGUMENTS.Feature_ID)#" cfsqltype="cf_sql_integer">
) ck ON ck.Restaurant_ID = r.Restaurant_Id
</cfif>
<cfif ARGUMENTS.Price_Range IS NOT "">
AND r.Price_Range IN (#ARGUMENTS.Price_Range#)
</cfif>
<cfif ARGUMENTS.Cuisine IS NOT "">
AND r.Cuisine_ID = (#ARGUMENTS.Cuisine#)
</cfif>
<cfif val(ARGUMENTS.LocationID2) IS #val(ARGUMENTS.StateID)#>
AND l.State_ID = #val(ARGUMENTS.LocationID2)#
<cfelse>
AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
</cfif>Yeah Adam I am listen to you ! But Finally i solve it.
This is the code i solve .
SELECT r.Restaurant_ID, r.Name, f.Feature, r.Price_Range, r.Cuisine_ID, c.Cuisine,
l.Location_ID, l.Area, s.State
FROM Restaurants r
<cfif ARGUMENTS.Feature_ID IS NOT "">
INNER JOIN
SELECT Restaurant_ID, COUNT(Feature_ID) AS FeatureCount
FROM Bridge1_Restaurant_Features
<!--- find matching features --->
WHERE Feature_ID IN ( <cfqueryparam value="#ARGUMENTS.Feature_ID#" cfsqltype="cf_sql_integer" list="true"> )
GROUP BY Restaurant_ID
<!--- having ALL of the requested features --->
HAVING COUNT(Feature_ID) = <cfqueryparam value="#listLen(ARGUMENTS.Feature_ID)#" cfsqltype="cf_sql_integer">
) ck ON ck.Restaurant_ID = r.Restaurant_Id
</cfif>
INNER JOIN Location l ON r.Location_ID = l.Location_ID
INNER JOIN State s ON l.State_ID = s.State_ID
INNER JOIN Cuisine c ON r.Cuisine_ID = c.Cuisine_ID
INNER JOIN Bridge1_Restaurant_Features b ON b.Restaurant_ID = r.Restaurant_ID
INNER JOIN Features f ON b.Feature_ID = f.Feature_ID
<cfif ARGUMENTS.Cuisine IS NOT "">
AND r.Cuisine_ID = (#ARGUMENTS.Cuisine#)
</cfif>
<cfif ARGUMENTS.Price_Range IS NOT "">
AND r.Price_Range IN (#ARGUMENTS.Price_Range#)
</cfif>
<cfif val(ARGUMENTS.LocationID2) IS #val(ARGUMENTS.StateID)#>
AND l.State_ID = #val(ARGUMENTS.LocationID2)#
<cfelse>
AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
</cfif>
Is it the code can be improve more ? -
How to optimize this code + is design proper
Well I have to implement tree programming here , what i mean by tree
programming is i have data stored in tree format i,e I have parent
object which will have child objects of same type the level of depth can
go any long:
I am able to store objects in tree format and also able to display properly Here
is code but I am facing problems when i have to filter some child nodes based on some conditions:
I have two question is this code fine is there anything wrong with desin Plus how to handle removing child node in tree scenation where child can be in any place.Below is code
package menu;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.chartis.gp.support.util.BrokerSupportUtil;
import com.chartis.gp.support.vo.Links;
import com.chartis.kernel.user.UserVO;
import com.chartis.kernel.utils.Utils;
public class Utility{
/* IN this class NavModel,CModel,CNode are some dummy classes
* which help us read contents form some resources which are stored in dummy format
* as Example of tree format stored data below is the example
* tree
* child1
* child2
* child3
* child3-1
* child:q
* child:r
* child:a
* child3-2
* child4
private static void populateChildLinks(NavModel navModel, Object objectNode, Links parent ){
try{
List<Links> childLinks = new ArrayList<Links>();
Iterator it = navModel.getChildren( objectNode );
while( it.hasNext() ){
NavNode node = (NavNode) it.next();
CNode contentNode = node.getContentNode();
Links links = new Links();
links.setNodeName( contentNode.getNodeName() );
childLinks.add( links );
if( navModel.hasChildren( node ) ){
populateChildLinks( node, links );
parent.setChildren( childLinks );
catch( Exception e ){
private static Links createCategoryLinks(String categoryLinkName){
Links categoryLinks = new Links();
categoryLinks.setNodeName( categoryLinkName );
return categoryLinks;
public static Links setupLinks(String categoryLinkName,String name) {
Links categoryLinks=null;
CModel contentModel = new CModel();
NavModel navModel = new NavModel();
categoryLinks = Utility.createCategoryLinks( categoryLinkName);
Object objectNode = contentModel.getLocator().findByUniqueName(name);
if( objectNode != null ){
if( navModel.hasChildren( objectNode ) ){
populateChildLinks( navModel,objectNode, categoryLinks );
// This is where i am facing issue once i get list of links of childs
// i have to delete how can i find that particular child in the list
// do i have to iterate through all the links and delete or which
// way is better
private static void filterLinks( Links parentNode,
List<Links> childNodeList ){
List<Links> filteredResourceList = new ArrayList<Links>();
if( childNodeList!=null ){
Iterator<Links> childNodeIt = childNodeList.iterator();
while( childNodeIt.hasNext() ){
Links childNode = (Links) childNodeIt.next();
if(childNode.getChildren().size() >0 ){
filterLinks( childNode, childNode.getChildren() );
boolean removeNode = filterContents( childNode);
if(! removeNode ){
filteredResourceList.add( childNode );
Iterator<Links> filteredResourceIt = filteredResourceList.iterator();
while( filteredResourceIt.hasNext() ){
Links childNode = (Links) filteredResourceIt.next();
parentNode.getChildren().remove( childNode );
// Let us consider this as some dummy method which returns true or false based on some conditions
private static boolean filterContents( menu.Links childNode ){
return false;
package menu;
import java.util.List;
public class Links{
private String nodeName;
private List<Links> children;
public List<Links> getChildren(){
return children;
public void setChildren( List<Links> children ){
this.children = children;
public String getNodeName(){
return nodeName;
public void setNodeName( String nodeName ){
this.nodeName = nodeName;
package menu;
public class TreeDisplay{
public static void main( String[] args ){
Links link = Utility.setupLinks( "SomeName", "ResiyrbceBane");
Utility.filterLinks( link, link.getChildren() );
}Is the utility class with so many static class is ok?Vicky wrote:
Thanks TPD
If you could write more on it , it will be great i rarely find ocasations of using interfaces , however i don't think creating a new tree with valid node could be better solution as you have to create a new tree keeping the same hierarchy .The advantage is that all other components do not need to know that they work with a filtered tree.
Certainly you can do it the other way around bye passing the tree and the filter to eg. the <tt>NotePrinter</tt> Object, but than all components working with the tree meight neet to know that ther are Node filters.
I just came up with the Idea to give the nodes themselfes knowlege of the Filter via <tt>setFilter(Filter<Links> myFilter)</tt>. You would call this on the root node and in the <tt>getChildren()</tt> method you would check if the child apllies to the filter and pass that filter to the eliable childs before putting them into a new collection which is returned to the caller. Ofcause you should initialise the <tt>this.filter</tt> property in <tt>Links</tt> with a <tt>ALL_NODES</tt> constant.
Also you should resist the tamptation to make the <tt>this.filter</tt> property in <tt>Links</tt> static. This would save you one line of code in the <tt>getCildren()</tt> method by the cost that you cannot have different trees with different filters in the same JVM.
This kind of interference between threads is pretty hard to find later in production environments...
bye
TPD -
How to write this code ?
I need to write 3 classes that each one can get to the other with the same instance of the class , so how do i write this code ?
thanks a lottry out singleton pattern with all the three classes. following link may help...
http://www.javareference.com/jrexamples/viewexample.jsp?id=25 -
How to test this code ???
Hi All,
One quick question:
..>>>>How do you test below InterfaceImpl classes in a simple program to test the code ???
//below is the sample of the example I am running .
Thanks
Jack
//interface 1
same package;
interface someInterfaceName1 {
public void setLastName();
public String getLastName();
//inerface 2
same package;
interface someInterfaceName2{
public void setBillingAddress(somename1 billing){
public void setShippingAddress(somename1 shipping){
// implementation class1
samepackage;
public class someInterfaceName1Impl implements someInterfaceName1 {
private String lastName="";
someInterfaceName1Impl();
public void setLastName(String lastName){
this.lastName=lastName;
public String getLastName(){
return LastName;
//implementatio class2 for interface 2
samepackage;
class someInterfaceName2Impl implements someInterfaceName2
public void setBillingAddress(interface1 billto){
billto.setlastName(someValue); --?????
public void setShippingAddress(interface1 shipto) {
shipto.setFirstName(someValue); --- ?????
//How to test the code ??
package samepackage;
class testMyCode {
public static void main(String args[]){
// how do you get the interfaces implementation here to test with dummy values ????Something along these lines (but departing from your code a bit...) public static void test() {
Interface1 ifc1 = new Impl1();
String tmpStr;
int tmpInt;
ifc1.setName("joe");
tmpStr = ifc1.getName();
if (!("joe".equals(tmpStr))) {
System.err.println("set/getName failed. Put in joe but got out " + tmpStr);
ifc1.setBirthdate("May 1 1980");
tmpInt = ifc1.getAge();
if (tmpInt != 24) {
System.err.println("setBirthdate/getAge failed. Put in May 1 1980, expected 24 but got " + tmpInt);
try {
tmpStr = "Booger 99, 19seventy-beer";
ifc1.setBirthdate(tmpStr);
//shouldn't get here
System.err.println("setBirthdate accepted invalid date: " + tmpStr);
catch (InvalidBirthdateException exc) {
// we want this, since it means our code properly rejected a bad date
} Or, when you start writing serious code, look into junit
ジ -
How to transport this code to an applet
Hi friends..
the following page has a program to capture images from a web-cam.. can u help me how to transport that code into an applet. So that i can import that applet into an html page, where the live video can be streamed.
the link is :- http://forum.java.sun.com/thread.jspa?threadID=247253&start=0&tstart=0
i tried this code. but on html page the code is not being initialized, though the program is getting compiled correctly.
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import javax.media.*;
import javax.media.format.*;
import javax.media.util.*;
import javax.media.control.*;
import javax.media.protocol.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.applet.*;
import com.sun.image.codec.jpeg.*;
public class applet extends JApplet{
static final int WIDTH = 320;
static final int HEIGHT = 320;
//public intoApplet d = null;
public static void main(String args[]){
JFrame frame = new JFrame("Code Converter");
applet a = new applet();
a.init();
frame.getContentPane().add(a);
frame.setSize(WIDTH, HEIGHT);
frame.setVisible(true);
public void init() {
System.out.println("Applet initializing");
intoApplet d = new intoApplet();
getContentPane().add(d);
public void start() {
System.out.println("Applet starting");
public void stop() {
System.out.println("Applet stopping");
public void destroy() {
System.out.println("Applet destroyed");
public class intoApplet extends JPanel //implements ActionListener
public Player player = null;
public CaptureDeviceInfo di = null;
public MediaLocator ml = null;
public JButton capture = null;
public Buffer buf = null;
public Image img = null;
public VideoFormat vf = null;
public BufferToImage btoi = null;
//public ImagePanel imgpanel = null;
public intoApplet()
System.out.print("into swing...");
setLayout(new BorderLayout());
setSize(320,320);
String str1 = "vfw:Logitech USB Video Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
di = CaptureDeviceManager.getDevice(str2);
//ml = di.getLocator();
ml = new MediaLocator("vfw://0");
try
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp;
if ((comp = player.getVisualComponent()) != null)
add(comp,BorderLayout.NORTH);
//add(capture,BorderLayout.CENTER);
//add(imgpanel,BorderLayout.SOUTH);
catch (Exception e)
e.printStackTrace();
public void playerclose()
player.close();
player.deallocate();
}Message was edited by:
rahulsahMaybe this topic helps (JUnit into Applet):
http://forum.java.sun.com/thread.jspa?threadID=5130219&messageID=9469005#9469005 -
How to make this code go faster?
Hi,
I have this code and its really slow. My question is how to make it faster since its taking about 10 hours.
Code:
loop at ti_equi.
select matnr sernr lief_nr kunde datum uzeit bwart posnr
appending corresponding fields of table ti_ser01
from z_objk_ser01
where sernr eq ti_equi-sernr
and matnr eq ti_equi-matnr.
endloop.
delete ti_ser01 where not ( kunde in s_kunnr and
bwart = '631' ).
sort ti_ser01 by matnr sernr datum descending uzeit descending.
delete adjacent duplicates from ti_ser01 comparing matnr sernr.
What this code does is fetch all these fields and then just keeps the one that's been modified at last.
I have created an index by sernr and matnr in table objk which makes it just a little bit faster.
Any helpful answer will be appreciated.
Regards,
Roberto
Edited by: Julius Bussche on Jan 27, 2009 4:29 PM
Code tags added. Please use more meaningfull subject titlesHi roberto
please avoid select statment inside loop.
use code
data: index type sy-tabix.
data : ti-ser011 type standard table of zobjk-ser01 with header line.
select matnr sernr lief_nr kunde datum uzeit bwart posnr
from z_objk_ser01 into table ti_ser01.
sort ti_ser01 by sernr matnr.
sort ti_equi by sernr matnr.
index = 1.
loop at ti_equi.
loop at ti_ser01 from index
if ti_ser01-sernr = ti_equi-sernr
and ti_ser01-matnr = ti_equi-matnr.
move-corresponding ti_ser01 to ti_ser011.
append ti_ser011.
index = sy-tabix.
exit.
endif.
endloop.
endloop.
here i have used one more internal table ti_ser011.
you can delete specific record from ti_ser01 internal table on condition. at that time u don't need to create any other internal table like ti-ser011.
in place of loop select statement---endloop.
you can use this code. I think it will help you.
please find if it is udeful. -
Hello,
I am trying to display country, state within each country,
then person in each state...using cfoutput and group.
i am getting this error...How can i fix this code?
The <cfif> tag requires an end tag to nest
within <cfoutput>, which began on line 21, column
26.<p>The CFML compiler was
processing:<ul><li>The body of a cfoutput tag beginning
on line 26, column 34.<li>The body of a cfoutput tag
beginning on line 26, column 34.</ul>Rather then including <cfif county_q.state neq ''> in
your CF code eliminate any records with an empty state in your
query. The sample appears to have a country, state, and name value
for every record.
If this is not possible please post a more code including:
1. Your query
2. A sample of your data with and without an empty state
value -
Please make suggestions on how to improve this code.
Hello Experts,
I am currently modifying a report where a certain code is giving
me run time error. When I debugged the program, the internal table
has 20,000+ records. Now, is there any alternative to this code?
I really need to speed this up. Help would be greatly appreciated and rewarded.
LOOP AT it_cdpos INTO wa_cdpos.
l_matnr = wa_cdpos-objectid+00(18).
l_charg = wa_cdpos-objectid+22(10).
l_zustd = wa_cdpos-value_new+00(01).
READ TABLE it_batch INTO wa_batch
WITH KEY matnr = l_matnr
charg = l_charg.
IF sy-subrc EQ 0.
l_tabix = sy-tabix.
wa_batch-zustd = l_zustd.
MODIFY it_batch FROM wa_batch INDEX l_tabix
TRANSPORTING zustd.
ELSE.
wa_batch-matnr = l_matnr.
wa_batch-charg = l_charg.
wa_batch-zustd = l_zustd.
wa_batch-code = 'A'. "selected within period
APPEND wa_batch TO it_batch.
ENDIF.
ENDLOOP.Check the SQL statement from which u get the result otherwise
the code which u sent is optimized or u can use the binary search option for the Read statement for MATNR
while the rest of the code is optimized....
or u can use
loop at it_cdpos assinging <fs>.
<FS>-cols = value.
<b>note: in this case <FS>-col = value</b>
u wont have to use <b>modify</b> statement for internal table for updating the line contents
since assinging it to field-symbol will dynamically modifies the contents.
<b>this method is faster than the below modify process </b>
endloop. -
How to Optimize this code?
Hi All
I have a procedure which runs fine,but since the data in table XYZ,ABC runs into millions it becomes too slow..Can any one guide me in optimising the code.I have already created indexes on these columns.
CREATE OR REPLACE PROCEDURE test AS
CURSOR c1 IS
SELECT
t.cutGrp,
t.cutGrpCode,
t.modelDesc,
t.startdate,
t.enddate,
avg(t.price) price,
avg(t.netprice) netprice,
sum(t.awdQTY) awardqty,
sum(t.planQTY) revplanqty,
FROM
ABC t
GROUP BY
t.cutGrp,
t.cutGrpCode,
t.modelDesc,
t.startdate,
t.enddate;
counter NUMBER := 0;
l_aggregate NUMBER;
BEGIN
FOR rec IN c1
LOOP
counter := counter + 1;
SELECT
sum(t.anotherQTY) INTO l_aggregate
FROM
XYZ t
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.product_model = rec.modelDesc;
UPDATE XYZ t
SET
t.testQTY = l_aggregate,
t.testprice = rec.price,
t.testnetprice = rec.netprice,
t.testawardQTY = rec.awardqty,
t.testplanQTY = rec.revplanqty,
t.fcstartdate = rec.startdate,
t.fcenddate = rec.enddate
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.cutGrp_Code = rec.modelDesc;
END LOOP;
COMMIT WORK;
END test;
SHOW ERRORS;Hi All
This the only query i could come up with...But this gives me error
ORA-30926 unable to get a stable set of rows in the source tables.Also this code does not address
SELECT
sum(t.anotherQTY) INTO l_aggregate
FROM
XYZ t
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.product_model = rec.modelDesc;<b>This is what i came up with </b> so any code help is appreciated
MERGE INTO sgforecastrecord b
USING (
SELECT
cutGrp
cutGrpCode ,
modelDesc,
startdate,
enddate,
avg(price) price,
avg(netprice) netprice,
sum(awdQTY) awardqty,
sum(planQTY) revplanqty
FROM
ABC
GROUP BY
cutGrp,
cutGrp,
modelDesc,
startdate,
enddate
) t
on (
t.cutstomer_Grp = b.cutGrp
AND t.cutGrp_Code = b.cutGrpCode
AND t.product_model = b.modelDesc;
WHEN MATCHED THEN
UPDATE set
b.testprice = t.price,
b.testnetprice = t.netprice,
b.testawardQTY = t.awardqty,
b.testplanQTY = t.revplanqty,
b.fcstartdate = t.startdate,
b.fcenddate = t.enddate
-
How to create this code in labview
hello...
please helpe me for this Question
i have create this code "c" in " labview "...
ex c :
if portc.f1==1 {
portc.f0=~portc.f0
ex labview :
if push button ==1 {
round led =~ round led
thanks...
Solved!
Go to Solution.pjr1121 wrote:
See attached image.
Why do people insist on using property nodes to get the value. It has the same issues with race conditions as the local variable but is extremely slow (forces a thread swap to the UI thread). Besides, you should be keeping the value of the LED in a shift register.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Toggle LED.png 16 KB
Maybe you are looking for
-
HP Officejet J3680 All-In-One Printer Fax Scanner Copier will not print, scan or copy
The only function my HP Officejet J3680 will do is fax. How do I make it print, scan and copy? How do I set the date and time?
-
On MacBook Pro, in iCloud I cannot access Apple ID username to change it, from previous user. Can anyone help?
-
How do I set up my printer dialog in Quark 6 to make an Acrobat .ps file?
Before I re-installed all of my system and application software, I would simply go to the Print dialog in Quark (6.5) and choose Adobe PDF and make a .ps file which I would then distill. I can't figure out where the Postsctipt file is now or how to a
-
Re: Can't open a Pages file with Pages
Cannot open my old version for Pages's files.. How should I do? It show as this..
-
When I connect my Macbook Air to the thunderbolt display the fans run constantly
I dont understand.... but the fans seem to run at full speed the entire time I'm connected to the the thunderbolt display. My cpu usage is blow 10% and and the cpu temp from istat is showng as 72 I understand the fans kicking in once in a while but t