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 ”
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{
Name:
}
res[‘Content-Type’] = “text/html”
end
end
class Dataread < HTTPServlet::AbstractServlet
def do_GET(req,res)
res.body = %Q{
Welcome
}
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
Wrapster Aol wrote:
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 ”
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{
Name:
}
res[‘Content-Type’] = “text/html”
end
end
class Dataread < HTTPServlet::AbstractServlet
def do_GET(req,res)
res.body = %Q{
Welcome
}
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
Hi Wrapster,
Forvive the late reply, but I only just joined up 
You could replace the text between your <>'s to #{req.query[‘text1’]}
Cheers,
Brad