how to pass data in webrick sevelts? please help


 
Thread Tools Search this Thread
Top Forums Web Development how to pass data in webrick sevelts? please help
# 1  
Old 01-29-2009
how to pass data in webrick sevelts? please help

Hi all,

I am a newbie to servlet programming using webrick...
Was wondering how to accept data from a form and do necessary
processing..
To start with i wrote a sample servlet that accepts a name and prints
"welcome <name>"

But I do not know how to take this value from the form into the servlet
and print it out...
this is what i worte... can anyone please help me with this.

s = HTTPServer.new( :Port => 9000)
class TextServlet < HTTPServlet::AbstractServlet
def do_GET(req, res)
res.body = %Q{<html>
<form action = "text.rb">
Name:<input type = "text" name = "text1">
<input type = "submit">
</form>
</html>}
res['Content-Type'] = "text/html"
end
end

class Dataread < HTTPServlet::AbstractServlet
def do_GET(req,res)
res.body = %Q{<html>
<body>
Welcome <I dont know how to call it here>
</body>
</html>}
res['Content-Type'] = 'text/html'
end
end

trap("INT") {s.shutdown}
s.mount("/" , TextServlet)
s.mount("/text.rb", Dataread)
s.start

I am a total beginner to this , so please help me out....
Also if there is any resource online available do point me to it, apart
from webrick.org
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Problems starting webserver (WEBRick) on Rails

Good afternoon: I need your help please: Im new at web applications and i started taking a Ruby on Rails course and as a part of the installations i followed the instructions given on page: http://railsapps.github.io/installrubyonrails-ubuntu.html I followed every step and id did not yield... (6 Replies)
Discussion started by: alexcol
6 Replies

2. Shell Programming and Scripting

Pass some data from csv to xml file using shell/python

Hello gurus, I have a csv file with bunch of datas in each column. (see attached) Now I have an .xml file in the structure of below: ?xml version="1.0" ?> <component id="root" name="root"> <component id="system" name="system"> <param name="number_of_A" value="8"/> ... (5 Replies)
Discussion started by: Zam_1234
5 Replies

3. Shell Programming and Scripting

Converting variable space width data into CSV data in bash

Hi All, I was wondering how I can convert each line in an input file where fields are separated by variable width spaces into a CSV file. Below is the scenario what I am looking for. My Input data in inputfile.txt 19 15657 15685 Sr2dReader 107.88 105.51... (4 Replies)
Discussion started by: vharsha
4 Replies

4. Shell Programming and Scripting

How i can obtain differents data on a single pass?

#!/bin/bash for i in `ls -c1 /usr/share/applications` do #name=`cat /usr/share/applications/$i | grep ^Name= | cut -d = -f2` #categories=`cat /usr/share/applications/$i | grep ^Categories= | sed 's/;/=/g' | cut -d = -f2` name=$(grep ^Name= /usr/share/applications/$i | cut -d = -f2)... (12 Replies)
Discussion started by: alexscript
12 Replies

5. Shell Programming and Scripting

How to pass data from server (CGI script) to client (html page)

Hi I know how to pass data from client side (html file) to server using CGI script (POST method). I also know how to re-create the html page from server side after receiving the data (using printf). However I want to write static pages on client side (only the structure), and only to pass... (0 Replies)
Discussion started by: naamabm
0 Replies

6. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

7. Programming

issues regarding <frameset> usage in webrick servlets, pls help

Hi all, Ive been trying to execute <frameset> tags within webrick servlets.. But when the server is started i get erreneous o/p ... The html code if executed individually runs flawlesswelly but inside the servlet it cribs... Could anyone please help me out? (0 Replies)
Discussion started by: wrapster
0 Replies

8. Shell Programming and Scripting

pass curls progress/status data to a file

hello hackers again. please help me out once again. i have a script which executes CURL to fetch a file from the web and instantly outputs the files content to STDOUT. now my question - can i somehow write the progress-status to a file? so that curl acts silently (-s) and only puts... (0 Replies)
Discussion started by: scarfake
0 Replies

9. UNIX for Dummies Questions & Answers

Howto capture data from rs232port andpull data into oracle database-9i automatically

Hi, i willbe very much grateful to u if u help me out.. if i simply connect pbx machine to printer by serial port RS232 then we find this view: But i want to capture this data into database automatically when the pbx is running.The table in database will contain similar to this view inthe... (1 Reply)
Discussion started by: boss
1 Replies

10. UNIX for Advanced & Expert Users

pf not working properly even with only "pass in all" and "pass out all" rules

i have two rules in my pf.conf file, "pass in all" and "pass out all" i was having issues with getting pf working to begin with, so i went with starting from nothing and working on up. i have an ultrasparc ultra1 200e, with an added 4-port fast ethernet sbus card, running "3.4 GENERIC#85... (4 Replies)
Discussion started by: xyyz
4 Replies
Login or Register to Ask a Question