Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 28th, 2005, 04:53 AM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Servlet Tag Problem

Hello,

I have a servlet which is supposed to execute a shell command and display the output. The shell command is as follows and this is the output at the command line:

localhost:~#serctl ul show 2045
<sip:[email protected]>;q=1;expires=456778

However my servlet code which I have included below, only prints ";q=1;expires=456778". It leave out the line in the "<>". I suspect this is something to do with the tags. Can someone tell me how to fix this?

String[] command = { "serctl", "ul", "show", "2045" }; // Only change!

    Runtime runtime = Runtime.getRuntime();
    Process process = null;
    try {
      process = runtime.exec(command);
      BufferedReader in =
      new BufferedReader(new InputStreamReader(process.getInputStream()));

      // Read and print the output
      String line = null;
      while ((line = in.readLine()) != null) {
        out.println(line);
      }
    }
    catch (Exception e) {
      out.println("Problem with command");
    }

Many thanks in advance for the help,
Aisling.

 
Old June 28th, 2005, 05:58 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You shouldn't change anything in the servlet program. However, you need to HtmlEncode the result when you feed it to the control that displays it on the page. You can use Server.HtmlEncode which will change the < > to &lg; &gt;.

-Peter
 
Old June 28th, 2005, 08:38 AM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Im sorry im new to java!!...I still don't understand.

Will I change it to something like:

line = Sever.HTMLEncode(in.readline());

Many Thanks,
Aisling.

 
Old June 29th, 2005, 05:02 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to make that call in the ASP.NET code that calls the servlet and assigns the value to some web control (if I am understanding your scenario correctly).

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with servlet developer.ibm Servlets 1 September 12th, 2007 11:22 PM
Servlet Problem cziaul Servlets 2 April 28th, 2007 09:39 AM
My servlet problem saeed Servlets 1 April 10th, 2007 07:12 AM
Can/How i use Java Bean & Tag Library in servlet nigam.anand Servlets 0 May 9th, 2006 09:40 PM
Servlet tag problem odriscolla Servlets 0 June 28th, 2005 04:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.