Servlet output problem

hi
Im having a problem with reading some data out of my servlet textbox.
the user pastes some data into the textbox below and tixks the checkbox if
the first column is headings.
<BR><TEXTAREA NAME="Paste" ROWS="15" COLS="65"></TEXTAREA>
<ul>
<INPUT TYPE ="checkbox" NAME="firstcol" VALUE="First">First name is column name
//I save the parameters as below
          String table = request.getParameter("Paste");
          String firstcol=request.getParameter("firstcol");
               out.println(firstcol);
          session.setAttribute("table", table);
          session.setAttribute("firstcol", firstcol);
//then retrieve them
          String t= (String)session.getAttribute("table");
          String f= (String)session.getAttribute("firstcol");
          if(f.equals("First"))
          ColumnParser.column(t, writer);
          else //(f.equals(null))
          writer.println(t);
//the problem is it works fine if the user selects the checkbox and the column headings are printed out. But if the user doesnt select the checkbox, instead of the whole data being printed out I get an internal server error! I would be very grateful for any suggestions
thanks.           

The "internal server error" means that your code there threw an exception of some kind. You need to look into your servlet container's log files to find out exactly what it was -- there should be a stack trace in one of them. My bet is that you have a NullPointerException, since your code assumes that both parameters will be present in the request and does not check to see if either is null.

Similar Messages

  • Servlet output not displayed properly in Internet Explorer

    Hi All,
    I'm developing a servlet which uploads a file. After the servlet parses the request body, it stores the file contents as a binary string in the database. While displaying the contents of the attached file, the IE(Internet Explorer) is ignoring all the newlines and spaces. IThe same uploaded file when viewed through Firefox browser is being displayed properly. I've added some debug statements to print the filecontent before sending it to servlet output stream. They look exactly as they were in the uploaded file. The MIME type is application/octet-stream.
    I've also made the response to accept "ISO-8859-1" and "UTF-8" charsets, yet the IE is not rendering the file contents properly. The code looks like this,
    response.setContentType("text/html; charset= ISO-8859-1, UTF-8");
    byte[] buff = attachment.getAttachObject();
    OutputStream out = response.getOutputStream();
    out.write(buff);
    out.close();
    I've tried using PrintWriter also. I've tried changing the content types, character encodings of request and response objects, still couldn't resolve the issue. What really baffles me is that when it's displaying properly in Firefox, why can't it render properly in IE? I'm using Win XP SP2, and IE version is 6.0.29. The content which is being sent to the output stream contains newline and space characters, but they are not displayed in the browser. Did any one face this sort of issue? Your help is highly appreciated.
    Thanks,
    Tarun.

    Hi,
    Thanks for looking into the issue. Let me tell you that I've tried keeping various content-types like text/plain, text/xml etc, but in none of those cases the IE rendered the output properly. But with the same content-type i.e text/html or text/plain, Firefox is able to render the file content properly. I've tried a brutal force approach like below,
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    String str = new String(attachment.getAttachObject());
    char[] buff = str.toCharArray();
    for(i=0;i< buff.length; i++)
    int n = (int)buff;
    if(n == 10)
    out.println();
    else
    out.print(buff[i]);
    out.close();
    I was trying to print a newline whenever I find a newline character in the file content. Even this didn't work. Please suggest me some way to get rid of this problem.

  • Macbook mini DVI to DVI output problems

    hi
    I've been using a samsung syncmaster 22" with my macbook for about a year now with no problems using the mini DVI to DVI connection
    then earlier this week i used a different DVI cable to plug my playstation 3 into the screen, when i plugged the computer DVI cable back into the screen lots of red/pink pixels have taken over the screen and when the desk is nudged red lines flash up
    i thought it might be either the DVI cable or the mini DVI to DVI adapter and replaced both to no avail, i have also tested all the cables on other screens/with other computers, and tested the screen with my playstation. Screen and cables all work fine so i think it must be some kind of output problem, but cant work out what it could be seeing as nothing would have happened to the port on the actual computer whilst changing connections on the samsung screen
    sorry for the long winded post, really wanna know what the problem is here

    Hi cbeth,
    welcome to macbook forum.
    For your friend macbook, try to press F7 back and forth to switch between mirror and expanded mode.
    Try to update your macbook hardware firmware and software using software updater and repair permission after that...application/utilities/disk utility/repair permission.
    Also reset your PRAM and PMU.
    Open your friend system preference / display and try to compare and set yours similar to hers, including resolution, color depth, refresh rate.
    Good Luck.

  • Servlet Compilation Problem !

    Hi,
    I am just starting to learn servlets and I got problem in compiling them. I got compilation error in
    import javax.servlet.*;statement. Seems that the compiler cannot find the servlet package. I got J2EE 1.4 beta installed on my machine but there is no servlet.jar package. I am using J2SDK 1.4.1_02, J2EE 1.4 beta and Tomcat 4.1.24.
    Can anyone help me with my servlet compilation problem?
    Thanks in advance!
    Josh

    servlet.jar is here :
    <tomcatdir>\common\lib
    add it to your compiler classpath

  • Mac mini audio output problems

    This is similar to a problem that appeared before, but with a different twist.
    On 4 July all was well. On 5 July I switched on and there was no "chord" from the Mac. When I collected my mail - no sound from my speakers (which are part of my screen). Logged on to a couple of sites - no sound.
    The System Profiler, under the "Audio (Built In)" category, says: "No Built-in Audio." I know that's wrong because it's always worked before and when I plug my headset in it works fine.
    When I go to the Sound preferences panel in System Preferences, it finds the headset but if I unplug that it finds nothing.
    I tried running the hardware test (by putting in the OS X install disc and holding D during startup.) It couldn't find a problem.
    So, as far as I can see, audio output is fine for the USB headset output but not for the others. Is there a simple fix? The nearest Apple store is about 200 miles away and I don't fancy the idea of posting the Mac off.
    (And I think it's still under warranty for a couple more weeks.)
    Mac mini   Mac OS X (10.4.10)  

    hello mini users with the "no audio output" problem
    it seems that there are faulty output jacks in the macbook and the mac mini
    there are two things you can try:
    i tried everything and began thinking about what new software i had installed. it was "macam" which enables you to use older webcams on OSX. i needed that to use my webcam on skype.
    macam installs a file called "macam.component"
    if you have the same, do this - take that file out of:
    (your hard drive)/library/quicktime - macam.component
    and just put it on your desktop
    restart, then in your sound pref's choose your audio output (if doesn't work restart again)
    the first time i took it out, i had my sound back instantly, another time i had to choose audio output in sound prefs. you kind of have to try different things. after you get your sound back, you can put back "macam.component" to use your webcam.
    it seems macam causes the problem, the two can not work at the same time.
    the second thing: if you dont have "maccam" try plugging and unplugging output jack a few times and restarting until you have sound.
    the problem still could be with the OSX 10.4.10 update / quicktime...or maybe even a hardware problem like others with macbooks were saying (with the red light), not sure.
    people with macbooks and who have the red light on, say to use a paperclip to turn off the switch inside.
    my mini does not have a red light on. i tried using a paperclip but it doesnt work.
    hope this helps, beleive me i feel your pain!!!!
    what good is a computer without sound?
    extremely annoying problem that i hope apple looks into and fixes
    -andrew

  • Servlet chaining problem..

    import java.io.*;
        import javax.servlet.*;
        import javax.servlet.http.*;
        public class Deblink extends HttpServlet {
          public void doGet(HttpServletRequest req, HttpServletResponse res)
                                       throws ServletException, IOException {
            String contentType = req.getContentType();  // get the incoming type
            if (contentType == null) return;  // nothing incoming, nothing to do
            res.setContentType(contentType);  // set outgoing type to be incoming type
            PrintWriter out = res.getWriter();
            BufferedReader in = req.getReader();
            String line = null;
            while ((line = in.readLine()) != null) {
              line = replace(line, "<BLINK>", "");
              line = replace(line, "</BLINK>", "");
              out.println(line);
          public void doPost(HttpServletRequest req, HttpServletResponse res)
                                        throws ServletException, IOException {
            doGet(req, res);
          private String replace(String line, String oldString, String newString) {
            int index = 0;
            while ((index = line.indexOf(oldString, index)) >= 0) {
              // Replace the old string with the new string (inefficiently)
              line = line.substring(0, index) +
                     newString +
                     line.substring(index + oldString.length());
              index += newString.length();
            return line;
    What is pre request fo above code to work.
    I had tried this many time but it is not working, what will be calling servlet look like

    And can you explain why your title is "Servlet chaining problem"?

  • Delimited output problem at the time of writing in to text file

    Hi ,
    I am using matrix stayle design for my reports when i am generating reports in delimited format i am getting Delimited output problem(DR.Watson ERROR) at the time of writing in to textfile.

    Hi,
    Try with new desformat delimiteddata which is available with Report 6i patch 11.
    Thanks
    Oracle Reports Team

  • Converting servlets output to PDF fle

    How to convert Java Servlets output html file to PDF file or a Word document.

    not sure what u mean by 'convert' the output to PDF or word document
    Do you mean you want to force the browser to open file using MSWord / PDF viewer? If yes :
    For showing output as a word document, you can set the servlet response MIME type to 'application/ms-word' and set its extension to .rtf . You can then use a RTF template to build servlet output (since RTF is flat file format). By replacing placeholder tags in RTF template, you can generate content.
    For showing output as PDF, you'll need some library for PDF writing.
    hth,
    Subodh

  • Read Servlet output stream

    how can i read servlet output stream

    i m using SAX to create an XML.
    I set result to "Servlet Output Stream" as shown below :->
    SAXTransformerFactory saxTF = SAXTransformerFactory.newInstance();
    TransformerHandler th = saxTF.newTransformerHandler();
    Transformer t = th.getTransformer();
    StreamResult stRes = new StreamResult(res.getOutputStream());
    th.setResult(stRes);
    th.startDocument();
    what i want to wright the same xml result in file at the same time(parallel y).

  • Premiere Elements 12 output problem

    I am having problems outputting my project. Different errors messages.  One says transcoding error.  Another time it says export error.  Other times it crashes. And then the program won't even open. 
    Any suggestions?
    bwatson9

    Steve,
    First, thank you for your prompt response.  This is the first time I have used Premiere Elements 12.  I don't seem to have a manual for the software.
    The product was bought with my new computer.  I am using windows 8.1 (64-bit) with Intel Core i7-4770 CPU @ 3.40GHz.  I have 12 GB of installed RAM.  I have 1TB hard drive of which this is the first project I done. 
    I have checked to make sure that I am getting all Windows and Microsoft Updates.  I even manually went to Windows Update and installed the optional updates.
    The project is a 20 min. video using mostly photos and 2 small video clips.  The project is saved in its own folder.
    When I go to the timeline in Expert view I do see an orange-yellow line above the timeline.  It runs the whole length of the project.
    I understand from reading the FAQ's that each photo cannot be larger than 1000 x 750 pixels.  I will check that and reduce their size.  Is there anything else that I need to do?
    Where can I find a manual?
    Thanks,
    bwatson9
    Date: Sun, 23 Mar 2014 06:31:03 -0700
    From: [email protected]
    To: [email protected]
    Subject: Premiere Elements 12 output problem
        Re: Premiere Elements 12 output problem
        created by Steve Grisetti in Premiere Elements - View the full discussion
    A lot depends on a lot.
    What operating system are you using? What processor do you have and how much RAM and how much free space is on your hard drive?
    How long is your project? What model of camcorder is your video coming from and what format and resolution is it?
    Have you ensured that your project file is saved to its own folder, with no other project files in this folder?
    When you add your video to your timeline in Expert view, do you see a yellow-orange line above the clips, along the top of the timeline? This indicates a mismatch between project settings and video specs.
    If you are on a Windows computer, have you set up your computer to get both Windows and Microsoft Updates -- and have you manually gone to Windows Update and ensured you have even the optional updates that don't install automatically?
    When did you last run Disk Cleanup and Disk Defragmenter?
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6234402#6234402
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/6234402#6234402
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/6234402#6234402. In the Actions box on the right, click the Stop Email Notifications link.
               Start a new discussion in Premiere Elements at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • Graphic output problems in most programs - triangles ...

    - often at scrolling in the Finder
    - it appears spontaniously and dissappers/flicker if mouse is moving ...
    - in some programs it is permanent for example 3D Coat
    - different often and strong in different programs - in some there is no problem (5% - for example ZBrush)
    - Mountain Lion does not fix it - only some changes - for example Quicktime (not Fullscreen) a big triangle in the down left
    - little greeen/red pionts, like defect Pixels, in little groups are appearing too! - Photoshop, Final Cut Video Output...

    A screenshot give you a copy of what is actually sitting in the screen buffer.
    So this is not an "output" problem. That stuff has been messed up in the screen buffer.
    to draw the mouse cursor, the area around the pointer must be re-constructed. That is why moving the mouse cursor seems to "repair" it.

  • Print Output problem in ECC6

    Hi Friends,
    I am getting print output problem in ECC6.
    In VF03 I am giving issue output for invoice printing. Whenever I am presseing issue output one screen is coming for selecting output type. I have selected one output type and I pressed print preview then in print preview one item and corresponding amounts it is showing properly for the first time. But the problem is after the print preview if I come back and again if i press print preview button values are not getting refreshed and same item is repeated for twice and the amounts are also getting added. Again for the third time if i come back and again if i press print preview one more item is getting repeated and the amounts are also getting added which should not suppose to happen.
    What could be the problem and how to resolve it?
    Rewarded,
    Steve

    Hi,
    clear those variables in the program .
    Regards,
    Bharat.
    Reward points if helpful

  • Servlet Output Streams and clearing

    I am using servlets, and I want to be able to print something repeatedly. Well, that's not exactly true: I can print something repeatedly. Using a ServletOutputStream, it doesn't seem possible to clear what has already been written. Here's the code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    public class AlwaysTime extends HttpServlet {
         public void doPost(HttpServletRequest req, HttpServletResponse res)                throws ServletException, IOException {
              HttpServletResponse oldRes = res;
              Date now = new Date();
              res.setContentType("text/html");
              ServletOutputStream out = res.getOutputStream();
              out.println("<html>");
              out.println("<head>");
              out.println("<title>Clock</title>");
              out.println("</head>");
              out.println("<body>");
              out.println("<h1 align=\"Center\">");
              out.println(now.toString());
              out.println("</h1>");
              out.println("</body>");
              out.println("</html>");
              try {
                 Thread.sleep(1000);
              } catch (InterruptedException ie) {}
              // Do nothing: wait for 1 second.
              doPost(req, oldRes);
         public void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              doPost(req, res);
    }This code prints the time every second, but I want to clear the previous output stream. I thought the code shown above would work, but of course, oldRes points to the same object as res. But I don't know how to clear an output stream, so that it is completely empty. Instead, each of the new lines are appended to the same output stream.
    This doesn't only apply to servlet output streams: is there some way to clear the System output stream, for instance?
    But mainly the servlet output stream ...

    You would not want to use HTTP for this type of functionality. HTTP is known as a 'stateless' protocol that simply returns one exact response for each request. So, there is not way to 'clear' the stream (technically, you would not do so for 'normal' streams either, but when you add HTTP into the mix, the task is definitely not possible).
    You could implement the above using a RSS feed, or by using HTTP meta-refresh tags on the page itself ot resubmit the requests every second (though this would be inefficient). An applet would also do the task.
    - Saish

  • J Option Pane Output Problem

    Hi guys,
    I am new to Java and I am having trouble compiling this program via which I can calculate the number of months to pay off a loan.
    I am not sure why it is not compiling and would really appreciate some solutions or suggestions
    Thanks a lot.
    import javax.swing.JOptionPane;
    public class Final
    public static void main(String[] args)
    String LoanAmount;
    String Months;
    String AnnualInterestRate;
    String MonthlyPayments;
    double balance;               
    double interest;
    double payment;
    int months=1;
    LoanAmount=JOptionPane.showInputDialog("Enter Loan Amount:");
    AnnualInterestRate=JOptionPane.showInputDialog("Enter Interest Rate:");
    MonthlyPayments=JOptionPane.showInputDialog("Monthly Payments:");
    balance=Double.parseDouble(LoanAmount);
    interest=Double.parseDouble(AnnualInterestRate);
    payment=Double.parseDouble(MonthlyPayments);
    months=Integer.parseInt(Months);
    while (balance>0)
    {balance=(balance+(interest/12)*(balance))-payment;
    months=months+1;
    JOptionPane.showMessageDialog(null, "Number of Months ", +months);
    Edited by: Java1001 on Sep 15, 2009 11:45 PM

A: J Option Pane Output Problem

Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
You are passing 3 parameters -- a null, a String and an int -- to the JOptionPane#showMessageDialog method. In the [_API_|http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html], do you find a variant of this method that accepts these three parameters?
db

Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
You are passing 3 parameters -- a null, a String and an int -- to the JOptionPane#showMessageDialog method. In the [_API_|http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html], do you find a variant of this method that accepts these three parameters?
db

  • Stream Output problem when filename has Period( . ) within it in Servlet

    I have this code below that outputs the pdf file from a JSP using a servlet. The problem is if filename has period (.) (Ex. AAA.BBB.CCC.PDF) within it I gey a socket write error, and cant output the pdf file. Can anyone help me with this.
    Thank You
    JSP Code:
    document.write("<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" id=\"BravaDTXView1\" width=\"100%\" height=\"100%\"> ");
    document.write(" <param name=\"src\" value=\"/TifPdfDisplay?filepath=<%=sFilepath>\"> ");
    document.write("</object>");
    Servlet Code:
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding(Constants.GlobalVariable.CHARSET);
    String sFilePath= (String) request.getParameter("filepath");
    // Read in PDF test file
    File l_file = new File(sFilePath);
    FileInputStream in = new FileInputStream(l_file);
    int length = in.available();
    byte[] pdfbytes = new byte[length];
    in.read(pdfbytes);
    in.close();
    // Send response
    response.setContentType("application/pdf");
    response.setContentLength(pdfbytes.length);
    ServletOutputStream ouputStream = response.getOutputStream();
    ouputStream.write(pdfbytes, 0, pdfbytes.length);
    ouputStream.flush();
    ouputStream.close();
    }

    Hi all,
    I happen to solve the problem myself. The solution is striking simple. Just reduce the image size & bingo!
    Regards

  • Maybe you are looking for

    • Lightroom: Publish Services have gone corrupt

      When I was trying to sync 500px with Lightroom 5, all the Publish Services have initialised. SmugMug, Facebook, 500px, Revel, all have reset, and ask to be set up. When I try to set up any of them, I get an error promptly, as below: ?:0: attempt to i

    • IDoc acknowledgement with all error messages

      We are getting one IDoc in SAP from middleware and after it is processed we need to send acknowledgement back to sender system with all the messages in IDoc. I tried with ALEAUD msg type, but it seems it only send IDoc last status. However, requireme

    • Spry fields validations

      SUBMIT PROBLEM I have a webpage in a .cfm (ColdFusion) format to be used in a form. There are some Spry fields in it, like a validation text field. But I have some problems: When the user enters a wrong email format, the form does not do a submit. Th

    • Line selection in ALV

      Hi Experts! I need to make lines of ALV  multiselectable (like in table control) how can do that? I need to use ALV factory Message was edited by:         LOS'

    • Recurring Kernel Panic at startup- Ram ok- works only from DVD

      Hi everyone, Please help me figure this one out. After installing the latest ilok driver ( it might be a coincidence ) my Macpro 2.1 will go straight to Kernel Panic at start up. - It will start from the DVD drive, with the snow leopard installer or