# Problem with WEBRick and eruby

**URL:** <https://www.ruby-forum.com/t/problem-with-webrick-and-eruby/84342>\
**Category:** Ruby\
**Created:** [February 3, 2007, 10:01am UTC](https://www.ruby-forum.com/t/problem-with-webrick-and-eruby/84342 "2007-02-03T10:01:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 3, 2007, 10:01am UTC](https://www.ruby-forum.com/t/problem-with-webrick-and-eruby/84342/1 "2007-02-03T10:01:13Z")

</div>

Hi,

I am just starting in both ruby and web development so maybe the  
following pieces of code seem a sin for most of you.

I am writing a HTML form in a rhtml file and pass the parameters to  
antoher rhtml with embebed ruby.

The HTTP server is built as follows:

* * *

require ‘webrick’  
include WEBrick

def start\_webrick(config = {})  
config.update(:Port =\> 8080)  
config.update(:MimeTypes =\> {‘rhtml’ =\> ‘text/html’})  
server = HTTPServer.new(config)  
yield server if block\_given?  
[‘INT’, ‘TERM’].each {|signal|  
trap(signal) {server.shutdown}  
}  
ruby\_dir = File.expand\_path(‘/www’)  
server.mount(“/www”, HTTPServlet::ERBHandler, ruby\_dir)  
server.start  
end

start\_webrick(:DocumentRoot =\> ‘/www’)

* * *

the index.htrml is like follows

* * *
 METAR:   

* * *

And finally the response.rhtml is

* * *
\<% require 'cgi'

cgi = CGI.new

#Rest of code  
%\>

--------

The webrick server shows the following info while the loading of  
response.rhtml simply freezes

* * *

[2007-02-03 09:48:15] INFO WEBrick 1.3.1  
[2007-02-03 09:48:15] INFO ruby 1.8.5 (2006-08-25) [i386-mswin32]  
[2007-02-03 09:48:15] INFO WEBrick::HTTPServer#start: pid=1372  
port=8080  
nicalejo - - [03/Feb/2007:09:48:29 Romance Standard Time] “GET / HTTP/  
1.1” 200 1  
93

- → /  
[2007-02-03 09:48:43] ERROR `/response.rhtml’ not found.  
nicalejo - - [03/Feb/2007:09:48:43 Romance Standard Time] “POST /  
response.rhtml  
HTTP/1.1” 404 284  
[http://localhost:8080](http://localhost:8080) → /response.rhtml  
(offline mode: enter name=value pairs on standard input)

* * *

Why this offline message? Any suggestion?

Thanks in advance to the rubyists

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 3, 2007, 10:27am UTC](https://www.ruby-forum.com/t/problem-with-webrick-and-eruby/84342/2 "2007-02-03T10:27:15Z")

</div>

On 2/3/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> ## trap(signal) {server.shutdown} the index.htrml is like follows
> 
> ## [2007-02-03 09:48:15] INFO ruby 1.8.5 (2006-08-25) [i386-mswin32] [http://localhost:8080](http://localhost:8080) → /response.rhtml (offline mode: enter name=value pairs on standard input)
> 
> Why this offline message? Any suggestion?
> 
> Thanks in advance to the rubyists

Hi,  
CGI expects data on stdin (see the message). The problem is that  
webrick doesn’t pass it to ERB pages as such. Look at ERB handler how  
the vars are actually sent (I suppose there would be some @request or  
similar).
