Problems with the xsl element ---- xsl:output method="xml"/ ----
Hy, my problem is the next, I am trying to read a xml file and transform it in itself but when I do with XSLT, Internet Explorer doesnt show a xml file, just show me the text nodes of the xml file. I have the element <xsl:output method="xml"/>" in the xsl file but I dont Know what Iam doing wrong.
The next code is from the xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:copy-of select="catalog"/>
</xsl:template>
</xsl:stylesheet>
The next code is from the xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<?xml-stylesheet type="text/xsl" href="PlantillaXSL.xml"?>
<catalog dni="4546545">
<cd numero="2" id="5" color="red">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
The result in internet explorer is:
Bob Dylan USA Columbia 10.90 1985
All right. I asked because it's unusual to use the ".xml" extension for an XSL file, so I thought it might be an error. But there's nothing wrong with that.
Next debugging step: is that XSL file actually being used? Insert some debugging code in it so that you can tell.
Similar Messages
-
Problem with Cell size in Excel output of XML report
Dear all,
I am facing a problem with cell size when i run my XML report in Excel output. I found that it imitates the cell size of whatever i gave in the RTF. I cannot increase the cell size in RTF as my report contains 60 columns and max width of MS Word table is 22 inches.
Can any one suggest a way of doing this which shows full data in Excel sheet depending on the column data size with out any word wrap.
Thanks
RAJHi ,
You can try with
<xsl:attribute xdofo:ctx="block" name="wrap-option">no-wrap</xsl:attribute>
may be helpful to you
Thanks,
Ananth
http://bintelligencegroup.wordpress.com/ -
Problems with the tag error-page in web.xml
hi all, here is my code in my web.xml:
<error-page>
<exception-type>java.sql.SQLException</exception-type>
<location>/ex.html</location>
</error-page>
it seems not to work, because my JavaBean where its the code to connect to my database and execute a query has an error i made it at purpose to see if the error page works, my JavaBean reports an error: column name not valid but the error-page didn�t work, i use a servlet which instantiates my JavaBean and then my servlet redirects to a JSP, obviouslly if an error occurs my servlet didnt redirect to any place, here is the code into my JavaBean, if anyone could help me i really appreciate it...
public BeanLista seleccionaCliente()
int nBandera = 0;
BeanList lp = new BeanList();
String cadena = "SELECT CODCLI, APEPATI FROM TESO.CLIENTE WHERE CODCLI like '2001120%' ";
try
context = new InitialContext();
pool = (DataSource)context.lookup("jdbc/PRUEBADS");
catch (NamingException ne)
ne.printStackTrace();
System.out.println("No se ha podido efectuar el Pool de Conexiones");
try
cc = pool.getConnection();
ResultSet rs = cc.createStatement().executeQuery(cadena);
cc.close();
while(rs.next())
BeanPrueba bp = new BeanPrueba();
bp.setCodcli(rs.getString(1));
bp.setApepat(rs.getString(2));
lp.add(bp);
return lp;
}catch(SQLException sql){
System.out.println("A ocurrido un error de SQL");
System.out.println("Error de SQl capturado como : "+sql.getMessage());
//sql.printStackTrace();
return lp;
}Can it be because you are catching your exception? Why don't you try throwing the same exception in the catch block and let the server handle it for you.
Just a guess... Hope it works.
VM -
T.code FBL5N: a problem with the print of the output list
Hi All,
with reference to the t.code FBL5N, I have a problem with the print of the output list of the report.
When I execute the print, I obtain one customer for each page printed.
I wonder if is possible to obtain more customers for each page printed.
Could anyone help me?
Thanks
Gandalf
Edited by: Umberto Gandalf on Dec 21, 2008 10:36 PMHi,
Though personally i havent tried this option, check the same
Go to Menu: Settings >> Switch List
This will make the value displayed in ALV format and then try taking print outs.
Regards,
Sridevi -
I had a problem with the hard disk on a 13" 2010 macbook pro. Replaced the hard disk with an Hitachi 1TB disk but when I tried to erase and format, it fails with input/output error and at other times saying unable to allocate memory. Any help much appreciated!
Zap the PRAM and Reset the SMC, then try again.
-
Problem with the preview window in Premiere Elements 10
Hi guys,
I have a question:
I have a new PC (data follow) and Adobe Premiere Elements 10.
My problem is that I see in the preview-window only one grey picture. The sound runs without problems! In other chats I red, that perhaps my graphic card is the reson of my problam. Is this thus? If so, how I can repair this?
PC:
AMD FX-8350 Eight Core Processor 4 GHrz
NVIDIA GeForce GTX 750 Ti
Do you need even more?
What I have already tried:
- Adobe Premiere Elements 10 anew inst.
- Graphics drivers update
- Check DirectX
- Windows Media Player and QuickTimePlayer anew Inst.
Already to many thanks for your help!!!!!
lg
Börniborni123
What computer operating system is your Premiere Elements 10 to run on?
You are involved in the Premiere Elements 10/NVIDIA GeForce issue whose full details (description and fix) are included
in the Announcement at the top of this forum. Copy for your convenience below.
You gave a lot of details but did not include the computer operating system. This information may be the key whether
the known fix will work for you. The known fix requires roll back of the driver version to about May 2013. If your computer
is Windows 8 or 8.1 64 bit, there may not be a driver old enough to resolve the issue. This may force you consider
a Premiere Elements version other than 10 or a different video card/graphics card for your computer. This issue is
specific for Premiere Elements 10 and the NVIDIA GeForce cards.
Copy of Announcement at top of this forum....
Premiere Elements 10 NVIDIA Video Card Driver Roll Back
If you are a Premiere Elements 10 user whose Windows computer uses a NVIDIA GeForce video card and you are experiencing
Premiere Elements 10 display and/or unexplained program behavior, then your first line of troubleshooting needs to be rolling
back the video card driver version instead of assuring that it is up to date.
Since October 2013 to the present, there have been a growing number of reports about display and unexplained workflow
glitches specific to the Premiere Elements 10 user whose Windows computer has a NVIDIA GeForce video card. If this
applies to you, then the “user to user” remedy is to roll back the NVIDIA GeForce video card driver as far as is necessary
to get rid of the problems. The typical driver roll back has gone back as far as March – July 2013 in order to get a working
Premiere Elements 10. Neither NVIDIA nor Adobe has taken any corrective action in this regard to date, and none is
expected moving forward.
Since October 2013, the following thread has tried to keep up with the Premiere Elements 10 NVIDIA reports
http://forums.adobe.com/thread/1317675
Older NVIDIA GeForce drivers can be found
http://www.nvidia.com/Download/Find.aspx?lang=en-us
A February 2014 overview of the situation as well as how to use the older NVIDIA GeForce drivers for the driver
roll back can be found
http://atr935.blogspot.com/2014/02/pe10-nvidia-video-card-roll-back.html
The following is the specific link in the above for determining what older NVIDIA GeForce GTX750Ti driver versions are
available to you.
Older NVIDIA GeForce drivers can be found
http://www.nvidia.com/Download/Find.aspx?lang=en-us
Please update us on your progress,
Thank you.
ATR -
Problem with the renameTO method in the Linux environment
Hi
I got a problem with the renameTO method in the Linux environment. The file is not moving.
This method is returning false. the same code executed successfully in Windows environment.
Can anyone give some fix to this one or an alternate solution to move the files in both windows and Linux.
boolean success;
File root = new File(tempPath);
File f = new File(root, phyFileName);
File dest = new File(targetPath);
success = f.renameTo(new File(dest, actualFileName));actualFileName = 400.doc
dest = /home/jboss-4.0.3/axsscm_1.0/axsscmDocuments/xchange/fileup/fshare/PO/1786JITHENDRA wrote:
Thanks for the prompt replyNo problem.
>
Can u solve the below doubt.
Will renameTo method wont work in Linux? If so why?Did you not read what I said? I suspect you are trying to rename a file so that it actually has to be moved to a different volume (partition or hard disk) so it won't work. One would have the same problem on Windows trying to rename a file on the c: drive to a name on the d: drive.
>
>
Can u give a sample or good link to do the above work which works fine in all environments.?Just follow the pseudo code I gave. 15 minutes work. -
Hello, i have a problem with the adobe photoshop elements 10 in the organizer impossible to use the magic mouse, Where can I configure this one?
Thank you.What do you mean by "impossible to use"? I use a magic mouse with PSE all the time. What are you wanting to do that isn't working?
-
Is there a problem with the 32bit installer for Premiere Elements 10.0?
When i download and unzip the program there is not setup.exe in the folder. There was no problem with the 64bit version.
Have you already installed Premiere Elements? If so there is no need to try to install the 32-bit version. The installer detects and installs the version appropriate to your operating system.
-
Has anybody had a problem with the mouse cursor lagging when navigating the drop down menus? this only started happening after a re-install. it only occurs in Photoshop elements 13 in the photo editing section,and no other application. My mouse drivers are up to date.Any help or advice would be most welcome.
Good day!
Please post Photoshop Elements related queries over at
http://forums.adobe.com/community/photoshop_elements
and please read this (in particular the section titled "Supply pertinent information for quicker answers"):
http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
Regards,
Pfaffenbichler -
Hello. I have a problem with my Photoshop Elements 12 programm. I had restart my computer and I wanted to instal my Photoshop Elements 12 again but the sytem didn't accept my serial number. I get no answer per Mail and I didn't reach someone on my phone. Can you help me please? Thanks a lot Nana
1) Apps are not part of the backup, only data stored by 3rd party apps. But you can redownload the apps for free again if you use the same account you did when you bought them the first time. http://support.apple.com/kb/HT2519
2) See this article http://support.apple.com/kb/HT1766 and find out what's in your backup.
3) Backup your itunes+ library (http://support.apple.com/kb/HT1382 and http://support.apple.com/kb/HT1751), which will copy your Mobile Applications folder, and save your iphone backup folder as well
In other words, maintaining a backup of your computer is essential.
When you resync your apps from your computer to the phone, make sure your computer is authorized again. http://support.apple.com/kb/HT1420 -
[SOLVED][GRUB]Install problem with the new method
Hi,
it is not my first install of Arch Linux but I have a problem with this new kind of installation method, especially with GRUB.
Here is my hard drives configuration :
/dev/sda1 -> SSD 120 GB ntfs (windows)
/dev/sdb1 -> HD 1 TB ext4 (data)
/dev/sdc :
/dev/sdc1 -> ext2 /boot
/dev/sdc2 -> swap
/dev/sdc3 -> ext4 /
/dev/sdc5 -> ext4 /home
During the installation, I installed grub (with grub-install) in /dev/sdc. I assumed it was the correct drive to install it but apparently not, Windows starts automatically and I don't have the grub menu.
Should I install my system again or is there a way to boot on the livecd and install it ?
Should I :
1) mount /dev/sdc3 in /mnt then /dev/sdc1 in /mnt/boot and finally /dev/sdc5 in /mnt/home
2) pacstrap /mnt grub-bios
3) arch-chroot
4) grub-install
Thank you.
Last edited by hiveNzin0 (2012-09-12 06:15:15)DSpider wrote:
If you set whatever drive "/dev/sdc" is (brand and model) to boot first in the BIOS, all you need to do is install a bootloader on Arch. You don't even need a separate boot partition. It will use the /boot folder on root partition. Then install os-prober (if you don't already have this installed) and re-generate the .cfg.
https://wiki.archlinux.org/index.php/Be … bootloader
The problem is that I cannot select another hard drive. The only one available for the boot order is the Samsung 830 series (/dev/sda with Windows).
The other options are the CD drive and removable disk.
I checked that this morning, maybe I was too tired. I will check again this evening.
But if I am right and I cannot select my intel SSD (containing my arch setup) for the boot order, would the solution I described work ? I don't see why not but my knowledge are basic in Linux.
Thank you again for your help. -
Crud, I keep getting the wrong outputs for the reverseArray. I keep getting "9 7 5 7 9" instead of "9 7 5 3 1". Can you guys figure it out? T.I.A (been trying to figure this prog out for quite some time now)
* AWT Sample application
* @author Weili Guan
* @version 1999999999.2541a 04/02/26
public class ArrayMethods{
private static int counter, counter2, ndx, checker, sum, a, size, zero;
private static int length;
private static int [] output2, output3, reverse, array;
private static double output;
private static double dblsum, dblchecker, average;
public static void main(String[] args) {
//int
//int [] reverse;
System.out.println("Testing with array with the values [1,3,5,7,9]");
size = 5;
array = new int [size];
reverse = new int [size];
array[0] = 1;
array[1] = 3;
array[2] = 5;
array[3] = 7;
array[4] = 9;
System.out.println("Testing with sumArray...");
output = sumArray(array);
System.out.println("Sum of the array: " + sum);
System.out.println();
System.out.println("Testing with countArray...");
output = countArray(array);
System.out.println("Sum of the elements : " + checker);
System.out.println();
System.out.println("Testing with averageArray...");
output = averageArray(array);
System.out.println("The average of the array : " + average);
System.out.println();
System.out.println("Testing with reverseArray...");
output2 = reverseArray(array);
output3 = reverseArray(reverse);
//System.out.print(reverse[4]);
System.out.print("The reverse of the array : ");
for(ndx = 0; ndx < array.length; ndx++){
System.out.print(reverse[ndx] + " ");
private ArrayMethods(){
public static int sumArray(int[] array){
checker = 0;
ndx = 0;
counter = 0;
sum = 0;
while(counter < array.length){
if (array[ndx] > 0){
checker++;
counter++;
if(array.length > 0 && checker == array.length){
while(ndx < array.length){
sum += array[ndx];
ndx++;
return sum;
else{
sum = 0;
return sum;
/*Computes the sum of the elements of an int array. A null input, or a
zero-length array are summed to zero.
Parameters:
array - an array of ints to be summed.
Returns:
The sum of the elements.*/
public static int countArray(int[] array){
checker = 0;
ndx = 0;
counter = 0;
sum = 0;
while(counter < array.length){
if(array[ndx] > 0 && array[ndx] != 0){
checker++;
counter++;
return checker;
/*Computes the count of elements in an int array. The count of a
null reference is taken to be zero.
Parameters:
array - an array of ints to be counted.
Returns:
The count of the elements.*/
public static double averageArray(int[] array){
dblchecker = 0;
ndx = 0;
counter = 0;
dblsum = 0;
while(counter < array.length){
if(array[ndx] > 0){
dblchecker++;
counter++;
if(array.length > 0 && checker == array.length){
while(ndx < array.length){
dblsum += array[ndx];
ndx++;
average = dblsum / dblchecker;
return (int) average;
else{
average = 0;
return average;
/*Computes the average of the elements of an int array. A null input,
or a zero-length array are averaged to zero.
Parameters:
array - an array of ints to be averaged.
Returns:
The average of the elements.*/
public static int[] reverseArray(int[] array){
ndx = 0;
counter = 0;
counter2 = 0;
if(array.length == 0){
array[0] = 0;
return array;
else{
//reverse = array;
while(ndx <= size - 1){
reverse[ndx] = array[4 - counter];
counter++;
ndx++;
System.out.print("H ");
return reverse;
/*Returns a new array with the same elements as the input array, but
in reversed order. In the event the input is a null reference, a
null reference is returned. In the event the input is a zero-length array,
the same reference is returned, rather than a new one.
Parameters:
array - an array of ints to be reversed.
Returns:
A reference to the new array.*/
}What was the original question? I thought it was
getting the desired output, " 9 7 5 3 1."
He didn't ask for improving the while loop or the
reverseArray method, did he?
By removing "output3 = reverseArray(reverse):," you
get the desired output.Okay, cranky-pants. Your solution provides the OP with the desired output. However, it only addresses the symptom rather than the underlying problem. If you'd bother yourself to look at the overall design, you might see that hard-coding magic numbers and returning static arrays as the result of reversing an array passed as an argument probably isn't such a great idea. That's why I attempted to help by providing a complete, working example of a method that "reverses" an int[].
Removing everything and providing "System.out.println("9 7 5 3 1");" gets him the desired output as well, but (like your solution) does nothing to address the logic problems inherent in the method itself and the class as a whole. -
Problems with the Proxy Programme--Please help
Hi All,
I have written a simple proxy server in the form of a servlet. I changed the proxy config of my browser to connect to this servlet hosted on the default context(http://localhost:8080) of the Tomcat 5.0.25 . Well , this servlet internally connects to the proxy of the corporate LAN . The logic that I have applied is as follows. The servlet gets the request from the client (ie the browser in this case) , extracts the headers and contents from the request, sets them to a new request that it forms and finally send this new request to the proxy. When the proxy responds, the servlet collects the response headers and contents adn writes them in its response. To sum up , this servlet transparently carries the requests and responses between the client(browser) and the corporate LAN proxy. Now the problem is this. Let's say , now I am accessing http://www.google.com.The browser sends a request to my servlet with the following headers as they are extracted by my servlet.
ProxyServer:::>posting request
ProxyServer:::>headerValue::> headerName = accept : headerValue=*/*
ProxyServer:::>headerValue::> headerName = referer : headerValue=http://www.google.com/
ProxyServer:::>headerValue::> headerName = accept-language : headerValue=en-us
ProxyServer:::>headerValue::> headerName = proxy-connection : headerValue=Keep-Alive
ProxyServer:::>headerValue::> headerName = user-agent : headerValue=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; UB1.4_IE6.0_SP1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
ProxyServer:::>headerValue::> headerName = host : headerValue=www.google.com
ProxyServer:::>headerValue::> headerName = cookie : headerValue=PREF=ID=1be27c0a74f198ca:TM=1082058853:LM=1082058853:S=bu6ORrygzm8AUkm8
ProxyServer:::>postRequest
I set these headers into a new connection opened to the proxy and post a fresh request to the proxy,which, in turn responds with the following headers.
ProxyServer:::>posted request successfully
ProxyServer:::>writing response
ProxyServer:::>writeResponse-->headerName = Proxy-Connection : headerValue = [close]
ProxyServer:::>writeResponse-->headerName = Content-Length : headerValue = [257]
ProxyServer:::>writeResponse-->headerName = Date : headerValue = [Tue, 13 Jul 2004 14:01:40 GMT]
ProxyServer:::>writeResponse-->headerName = Content-Type : headerValue = [text/html]
ProxyServer:::>writeResponse-->headerName = Server : headerValue = [NetCache appliance (NetApp/5.5R2)]
ProxyServer:::>writeResponse-->headerName = Proxy-Authenticate : headerValue = [Basic realm="Charlotte - napxyclt2"]
ProxyServer:::>writeResponse-->headerName = null : headerValue = [HTTP/1.1 407 Proxy Authentication Required]
ProxyServer:::>writeResponse exiting
ProxyServer:::>wrote response successfully
I write these headers back to the client. According to what I was thinking, the client ie the browser would open a new dialog box asking for username/password owing to the presence of the "Proxy-Authenticate " header. But it does not happen that way. Rather the browser stops responsding and displays a blank page. Does anyone know why it happens this way? I am pasting the server prog below for everybody's reference.
package server.proxy;
//import all servlet related classes
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
import java.net.*;
import server.resources.*;
//My Proxy server --->Currently it is very simplea and relies on
//other proxy servers of an already connected network.
public class ProxyServer extends HttpServlet
//stores the resource bundle
private ServerResBundle resBundle = null;
//checks for the mode of operation
private boolean proxySet = false;
private String proxy = null;
//storing the original System out/err etc
private PrintStream sysOutOrig = null;
private PrintStream sysErrOrig = null;
private InputStream sysInOrig = null;
//initialise certain features that are required later
public void init() throws ServletException
try
//initialise the resource bundle
this.initResBundle();
System.out.println("ProxyServer:::>res bundle init");
//set the mode of operation
this.setMode();
System.out.println("ProxyServer:::>mode set");
//set the system out and err --System.setOut etc
this.setSystemOutErr();
System.out.println("ProxyServer:::>in/out/err set");
}//End try
catch(Exception e)
System.out.println("Exception in init..."+(e.getMessage()));
throw new ServletException(e);
}//Edn
catch(Throwable e)
System.out.println("Irrecoverable Error...");
throw new ServletException(e);
}//End
}//End init
//method to init the resource bundle;
private void initResBundle()
this.resBundle = ServerResBundle.getBundle();
}//End
//method to set the mode of the server--proxy or direct
private void setMode()
//read the target proxy property from the bundle and
//if it is set,take that URL
String temp = (String)(this.resBundle.getResource(ResKeys.PROXY_SERVER));
if ( (temp != null) && (temp.length() > 0) )
this.proxySet = true;
this.proxy = temp;
temp = null;
}//End
}//End
//method to set the system out and err etc
private void setSystemOutErr() throws Exception
//keep a copy of the original system out and error
this.sysOutOrig = System.out;
this.sysErrOrig = System.err;
try
//read the options adn if they are set, take the values directly
String newOutStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_OUT));
String newErrStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_ERR));
if ((newOutStr != null) && (newOutStr.length() > 0))
System.setOut(new PrintStream(new FileOutputStream(new File(newOutStr),true),true));
}//End if
if ((newErrStr != null) && (newErrStr.length() > 0))
System.setErr(new PrintStream(new FileOutputStream(new File(newErrStr),true),true));
}//End if
}//End
catch(Exception e)
//restore the stuff
System.setOut(this.sysOutOrig);
System.setErr(this.sysErrOrig);
}//End
}//End
//this is where the proxy functionalities will be embedded
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,java.io.IOException
//conenction URL
URL target = null;
//conenction to the remote object
URLConnection targetConn = null;
//stores the OOS and the OIS
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try
//check for the mode of operation
if (proxySet)
URLConnection objects go through two phases: first they are created, then they are connected.
After being created, and before being connected, various options can be specified
(e.g., doInput and UseCaches). After connecting, it is an error to try to set them.
Operations that depend on being connected, like getContentLength, will implicitly perform the connection,
if necessary.
//for the URL to the proxy
target=new URL(this.proxy);
//conenct to the proxy
targetConn = target.openConnection();
//set the details of the connectuon
targetConn.setDoInput(true);
targetConn.setDoOutput(true);
targetConn.setUseCaches(false);
// If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog. If false, then no user interaction is allowed
targetConn.setAllowUserInteraction(true);
//connect to the remote object
// targetConn.connect();//call this only when all the request properties are set
System.out.println("ProxyServer:::>posting request");
//post the received request to the URL
this.postRequest(targetConn,req);
System.out.println("ProxyServer:::>posted request successfully");
System.out.println("ProxyServer:::>writing response");
//receive the response
//write the received response to the client
this.writeResponse(targetConn,resp);
System.out.println("ProxyServer:::>wrote response successfully");
}//End if
else
//currently this functionality is not supported
throw new ServletException(
(String)(this.resBundle.getResource(ResKeys.ERR_FUNC_NOTSUPPORTED)));
}//End
}//End try
catch(Exception e)
if(e instanceof ServletException)
throw (ServletException)e;
}//End
if (e instanceof IOException)
throw (IOException)e;
}//End
//wrap it up in ServletException
throw new ServletException(e);
}//End
}//End
//method to write the response back to the client
private void writeResponse(URLConnection targetConn,HttpServletResponse resp)
throws ServletException
//get all the header fields from the response connection and set them to the
//response of the servlet
Map headerFields = null;
Iterator headerFieldEntries = null;
Map.Entry header = null;
//stores the input stream to the conn
BufferedReader brConn = null;
//stores the writer to the response
PrintWriter prResp = null;
//checks if the proxy authentication needed or not
boolean proxyAuthReqd = false;
try
//juste ensuring that the proxy authentication is reset
proxyAuthReqd = false;
if( (targetConn != null) && (resp != null) )
//Returns an unmodifiable Map of the header fields.
//The Map keys are Strings that represent the response-header field names.
//Each Map value is an unmodifiable List of Strings that represents the corresponding
//field values
headerFields = targetConn.getHeaderFields();
//Returns a set view of the mappings contained in this map
Set temp = headerFields.entrySet();
//Returns an iterator over the elements in this set
headerFieldEntries = temp.iterator();
if (headerFieldEntries != null)
while (headerFieldEntries.hasNext())
Object tempHeader = headerFieldEntries.next();
if (tempHeader instanceof Map.Entry)
header = (Map.Entry)tempHeader;
Object headerName = header.getKey();
Object headerValue=header.getValue();
System.out.println("ProxyServer:::>writeResponse-->headerName = "+headerName+" : headerValue = "+headerValue);
//do not select the key-value pair if both the key adn the value are null
if ( ( headerName == null) && (headerValue == null) )
continue;
}//Enmd
if (headerValue != null)
List headerValList = null;
if (headerValue instanceof List)
headerValList = (List)headerValue;
}//End
if(headerValList != null)
for (int i=0;i<headerValList.size();i++)
Object headerValueStr = headerValList.get(i);
if (headerValueStr instanceof String)
//note that the header-key can not be null for addHeader
//I have made this temporary provision to make the programme work.
resp.addHeader(( (headerName==null)? ("null_header"+i) :(String)headerName),
(String)headerValueStr);
//check if the proxy authentication required or not
if (((String)headerValueStr).
indexOf(resp.SC_PROXY_AUTHENTICATION_REQUIRED+"") != -1)
System.out.println("ProxyServer:::>writeResponse-->proxy auth needed");
//proxy authentication is needed
proxyAuthReqd = true;
}//End
}//Ednd of
else if (headerValueStr == null)
resp.addHeader(( (headerName==null)? null :(String)headerName),
null);
}//End
}//End for
}//End if
}//End if
}//End
}//End while
}//End if
//get the writer to the client
prResp = resp.getWriter();
System.out.println("ProxyServer:::>writeResponse-->proxyAuthReqd="+proxyAuthReqd);
//juste test a simple header
System.out.println("Proxy-Authenticate = "+(resp.containsHeader("Proxy-Authenticate")));
//if the proxy asks you for authentication,pass on the same to the client
//from whom you have received the request.When this flag is true,the connection
//is closed by the remotehost adn hence any attempt to open in input steram
//results in an error ie IOException
if (!proxyAuthReqd)
//now get the content adn write it to the response too
brConn = new BufferedReader(new InputStreamReader(
targetConn.getInputStream()));
String tempStr = null;
while ((tempStr = brConn.readLine())!=null)
prResp.println(tempStr);
}//End while
//close the connections
brConn.close();
}//End if
else
prResp.println("Proxy Authentication needed...");
}//End
//close the streams
prResp.flush();
prResp.close();
}//End if
System.out.println("ProxyServer:::>writeResponse exiting\n");
}//End try
catch(Exception e)
throw new ServletException(e);
}//End
}//End
//method to post request to the internet
private void postRequest(URLConnection targetConn,HttpServletRequest req)
throws ServletException
//extract the header parameters and the body content from the incoming request
//and set them to the new connection
Enumeration reqHeaders = null;
//reads the incoming request's content
BufferedReader brReqRd = null;
PrintWriter prResWt = null;
//stores temp header names and values
String headerName = null;
String headerValue = null;
try
if( (targetConn != null) && (req != null) )
reqHeaders = req.getHeaderNames();
//extract a header adn set it to the new connection
while (reqHeaders.hasMoreElements())
headerName = (String)(reqHeaders.nextElement());
headerValue = req.getHeader(headerName);
targetConn.setRequestProperty(headerName,headerValue);
System.out.println("ProxyServer:::>headerValue::> headerName = "+headerName+" : headerValue="+headerValue);
}//End
System.out.println("ProxyServer:::>postRequest\n");
//establis the actual connection
//calling this method bfore the above loop results in IllegalStateException
targetConn.connect();
//NOTE : try reading from and writing into OIS and OOS respectively
//now read the contents and write them to the connection
// brReqRd = req.getReader(); //this hangs for some reason
brReqRd = new BufferedReader(new InputStreamReader(req.getInputStream()));
System.out.println("Got the reader..brReqRd = "+brReqRd);
if (brReqRd != null)
String temp = null;
//establish the printwriter
// prResWt = new PrintWriter(targetConn.getOutputStream(),true);
prResWt = new PrintWriter(targetConn.getOutputStream());
System.out.println("trying to read in a loop from brReqRd.. ready="+(brReqRd.ready()));
while( (brReqRd.ready()) && ((temp=brReqRd.readLine()) != null) )
System.out.println("In while::>temp = "+temp);
prResWt.println(temp);
}//Emd while
//close the streams adn go back
brReqRd.close();
prResWt.flush();
prResWt.close();
}//End
}//End outer if
System.out.println("ProxyServer:::>postRequest exiting\n");
}//End try
catch(Exception e)
throw new ServletException(e);
}//End
}//End
}//EndHi serlank ,
Thanks for your reply. Well , I initially I thought of not pasting the code,as it was too long. But I could not help it,as I thought I must show in code what I exactly meant. That's why I followed a description of my problem with the code. You could probably have copied the code and pasted it in one of your favourite editors to take a look at it. Did you,by any chance, try to read it on the browser? And as regards reposting the same message, I can say that I did it as I felt the subject was not quite appropriate in the first posting and I was not sure as to how I could delete/alter the posting. I am not asking for a code-fix,but some suggestions from some one who might ever have come across such a thing.Anyway, lemme know if you have any idea on it. Thanks... -
Problem with the GridBagLayout Manager
Hello i am new to Java Swing and i am facing a problem with the GridBagLayout layout manager . the code in question is attached. First compile and run the code. It will execute w/o probs . Then go to the "Console" tab. There the diff components (6 buttons and 1 text area) are haphazardly arranged where as all measures where taken to prevent it in the code. The GridBagLayout manager for this tab is not working properly please help.
The code in question:-
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class MainForm extends JFrame{
JTabbedPane jtp = new JTabbedPane();
Container generalContainer; // container for the general pane
Container consoleContainer; // container for the console pane
GridBagLayout consoleLayout = new GridBagLayout(); // GridBagLayout for the console
GridBagConstraints consoleConstraints;// GridBagConstraints for the console
public MainForm()
super("Welcome to Grey Griffin -- Network Simulator");
setSize(700,600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel generalPane = new JPanel();
generalPane.setLayout(new BoxLayout(generalPane, BoxLayout.Y_AXIS));
JPanel consolePane = new JPanel();
consolePane.setLayout(new BoxLayout(consolePane, BoxLayout.Y_AXIS));
JPanel designPane = new JPanel();
designPane.setLayout(new BoxLayout(designPane, BoxLayout.Y_AXIS));
JPanel outputPane = new JPanel();
outputPane.setLayout(new BoxLayout(outputPane, BoxLayout.Y_AXIS));
//Setting up Layout for all the tabs
//for general tab
FlowLayout layout= new FlowLayout();
generalContainer = generalPane;
layout.setAlignment(FlowLayout.CENTER);
generalContainer.setLayout( layout );
//for console tab
consoleContainer = consolePane;
consoleConstraints = new GridBagConstraints();
// *******Finished********
//********** All buttons text areas are declared here**********
//*******for the general tab**********
JButton generalCreate = new JButton("Create a New Network");
JButton generalOpen = new JButton("Open an Existing Network");
JButton generalSave = new JButton("Save the Network");
JButton generalSaveAs = new JButton("Save As..........");
JButton generalExit = new JButton("Exit");
//******END******
//*******for the console tab
//text area
JTextArea consoleCode = new JTextArea();
consoleCode.setEditable(true);
consoleCode.setMaximumSize(new Dimension(700,400));
consoleCode.setAlignmentX(0.0f);
//text area complete
//*******for the Console tab**********
JButton consoleCompile = new JButton("Compile Code");
JButton consoleSimulate = new JButton("Simulate Code");
JButton consoleReset = new JButton("Reset");
JButton consoleOpen = new JButton("Open script files");
JButton consoleSave = new JButton("Save script files");
JButton consoleConvert = new JButton("Convert Script files to graphical form");
//***************END****************
//Adding buttons and text areas to there respective tabs
// for the general tab
generalContainer.add(generalCreate);
generalContainer.add(generalOpen);
generalContainer.add(generalSave);
generalContainer.add(generalSaveAs);
generalContainer.add(generalExit);
//****END****
// for the console tab
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleOpen,0,0,1,1);
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleSave,1,1,1,1);
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleConvert,1,2,1,1);
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleCode,1,0,3,1);
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleCompile,2,0,1,1);
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleSimulate,2,1,1,1);
consoleConstraints.fill = GridBagConstraints.BOTH;
addComp(consoleReset,2,2,1,1);
//****END****
// adding the tabs
jtp.addTab("General",null,generalPane,"Choose General Options");
jtp.addTab("Design",null,designPane,"Design your own network!!");
jtp.addTab("Console",null,consolePane,"Type commands in console for designing");
jtp.addTab("Output",null,outputPane,"View output");
getContentPane().add(jtp, BorderLayout.CENTER);
//****END****
//This method is used to ad the buttons in the GridBagLayout of the Console tab
private void addComp( Component c,int row,int column,int width,int height)
// set gridx and gridy
consoleConstraints.gridx=column;
consoleConstraints.gridy=row;
//set gridwidth and grid height
consoleConstraints.gridwidth=width;
consoleConstraints.gridheight=height;
//set constraints
consoleLayout.setConstraints(c,consoleConstraints);
consoleContainer.add(c);
class TabManager implements ItemListener
Component tab;
public TabManager(Component tabToManage)
tab = tabToManage;
public void itemStateChanged(ItemEvent ie)
int index=jtp.indexOfComponent(tab);
if (index!=-1)
jtp.setEnabledAt(index,ie.getStateChange()== ItemEvent.SELECTED);
MainForm.this.repaint();
public static void main(String args[])
MainForm form = new MainForm();
form.setVisible(true);
}Thanks for the suggestions. I did away with the GridBagLayout Altogether :-D
and put all the buttons in a seperate JPanel and added that JPanel into the Console tabs container which was using a BorderLayout this time. Take a look
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class MainForm extends JFrame{
JTabbedPane jtp = new JTabbedPane();
public MainForm()
super("Welcome to Grey Griffin -- Network Simulator");
setSize(800,600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel generalPane = new JPanel();
generalPane.setLayout(new BoxLayout(generalPane, BoxLayout.Y_AXIS));
JPanel consolePane = new JPanel();
consolePane.setLayout(new BoxLayout(consolePane, BoxLayout.Y_AXIS));
JPanel designPane = new JPanel();
designPane.setLayout(new BoxLayout(designPane, BoxLayout.Y_AXIS));
JPanel outputPane = new JPanel();
outputPane.setLayout(new BoxLayout(outputPane, BoxLayout.Y_AXIS));
//Setting up Layout for all the tabs
//**for the general tab
Container generalContainer;
FlowLayout layoutGeneral= new FlowLayout();
generalContainer = generalPane;
layoutGeneral.setAlignment(FlowLayout.CENTER);
generalContainer.setLayout( layoutGeneral );
//**for the console tab
Container consoleContainer;
consoleContainer = consolePane;
consoleContainer.setLayout(new BorderLayout() );
//Creating buttonpanel for adding the buttons
JPanel buttonPanel1 = new JPanel();
buttonPanel1.setLayout(new GridLayout(1,3));
JPanel buttonPanel2 = new JPanel();
buttonPanel2.setLayout(new GridLayout(1,3));
// All buttons / text areas / images are declared here
//**Buttons for the general tab**//
JButton generalCreate = new JButton("Create a New Network");
JButton generalOpen = new JButton("Open an Existing Network");
JButton generalSave = new JButton("Save the Network");
JButton generalSaveAs = new JButton("Save As..........");
JButton generalExit = new JButton("Exit");
//declaring the buttons
JButton consoleCompile = new JButton("Compile");
JButton consoleRun = new JButton("Run");
JButton consoleReset = new JButton("Reset");
JButton consoleOpen = new JButton("Open script files");
JButton consoleSave = new JButton("Save script files");
JButton consoleConvert = new JButton("Convert Script files to graphical form");
//declares the textarea where the code is written
JTextArea consoleCode = new JTextArea();
consoleCode.setEditable(true);
consoleCode.setMaximumSize(new Dimension(500,600));
consoleCode.setAlignmentX(0.0f);
//Adding buttons and text areas to there respective tabs
//**Buttons and text pads for the general tab**
generalContainer.add(generalCreate);
generalContainer.add(generalOpen);
generalContainer.add(generalSave);
generalContainer.add(generalSaveAs);
generalContainer.add(generalExit);
//adding buttons to the button panel 1
buttonPanel1.add(consoleOpen);
buttonPanel1.add(consoleSave);
buttonPanel1.add(consoleConvert);
//adding buttons to the button panel2
buttonPanel2.add(consoleRun);
buttonPanel2.add(consoleReset);
buttonPanel2.add(consoleCompile);
//adding button panels and textarea
consoleContainer.add(buttonPanel1,BorderLayout.NORTH);
consoleContainer.add(consoleCode,BorderLayout.CENTER);
consoleContainer.add(new JScrollPane(consoleCode));
consoleContainer.add(buttonPanel2,BorderLayout.SOUTH);
//adding the tabs
jtp.addTab("General",null,generalPane,"Choose General Options");
jtp.addTab("Design",null,designPane,"Design your own network!!");
jtp.addTab("Console",null,consolePane,"Type commands in console for designing");
jtp.addTab("Output",null,outputPane,"View output");
getContentPane().add(jtp, BorderLayout.CENTER);
class TabManager implements ItemListener
Component tab;
public TabManager(Component tabToManage)
tab = tabToManage;
public void itemStateChanged(ItemEvent ie)
int index=jtp.indexOfComponent(tab);
if (index!=-1)
jtp.setEnabledAt(index,ie.getStateChange()== ItemEvent.SELECTED);
MainForm.this.repaint();
public static void main(String args[])
MainForm form = new MainForm();
form.setVisible(true);
}
Maybe you are looking for
-
Disable Preferences in Adobe Reader 7
Hello everybody, I have got a problem with Adobe Reader 7 on terminal servers (Windows 2000 SP4). All plug ins the users do not need are disabled. The last thing is, that I need to disable Preferences (Edit -> Preferences). Is that possible? If yes,
-
Workflow Step to Reject or Approve based on a page property
I have extended the MyProcess.java workflow process from the CQ5.5 training class, so that it sets the approve property to true or false, depending if the page contains any expired assets or not. So the next step is to publish the page if the approve
-
Assignment to CO Object in GRN loading
Hai SAP Guru We have a problem, we are loading mass GRN's through "BAPI" , during the loading it is giving the error A/c. 400000130 requires an assignmen to CO object. We have even seen the material valuvation , it is given to the above GL account
-
Hi to all, Please can any one tell me, how to designe Process Chain Step by Step. Or any Document Related to that. i shall be thankful to you for this. Regards Pavneet Rana
-
Dear All, I need everything written into columns like the below script does, however I was wondering if there was a way I could reduce my code. I can't give you data for this and I can't give you the column names. However the values held in the numer