Skip to main content

Accessing a servlet url without a web browser

8 replies [Last post]
ruwanin84
Offline
Joined: 2008-04-08
Points: 0

I am using Sun Application server 9.1
I want to access my servelt url using my java socket application.

when I use jboss server I can access my servlet using GET/MyServlet
But sun application server donot allow me to access the url using GET/

Could you please let me know the way to configure this for Sun application server 9.1?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jeanfrancois Arcand

Hi,

just to recap. You star GlassFish v2, open a telnet session and try to
get access to your Servlet, right? That should work with v2 (v3 is
broken in that particular scenario). Now reading the email thread, you
seems to have issues with v2, right?

Can you edit ${glassfish.home}/domains/domain1/config/domain.xml and
remove the following like:

restart GlassFish and test again? Not that if you use telnet you need to
type fast the request line as if the bytes are sent to Grizzly too
slowly, Grizzly will think it is a DoS and close the connection.

Thanks

-- Jeanfrancois

glassfish@javadesktop.org wrote:
> I switched to GlassFish V2.
>
> I deployed myservlet GlassFish which runs on port 8080
> I am using windows XP and type [b]telnet localhost 8080[/b]
> then it shows me a window titled Telnet localhost
> But when i tried to type GET /Myservlet it comes back to command prompt.
>
> Could you please let me know a way to test this using telnet? ( I wanna verify that can i invoke myservlet atleast using telnet)
> [Message sent by forum member 'ruwanin84' (ruwanin84)]
>
> http://forums.java.net/jive/thread.jspa?messageID=270267
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

writtmeyer
Offline
Joined: 2006-11-17
Points: 0

In addition to my previous post some insights.

First I can see what is happening to you on telnet. It has nothing to do with timeouts but with Windows' telnet client and Grizzly (most probably a bug within Grizzly). As soon as the first character is send (no matter which) the client returns.

I have done some wiresharking to see what is happening. On Windows XP the included telnet-implementation acts weird (though not incorrect). I have not seen this on any other OS which might be the reason, why I - and probably others on this forum and mailing list - didn't get your problem before.

So Windows' telnet client sends every typed key in a TCP-packet on its own. Any other telnet client sends complete lines. Now I guess this is a bug in Grizzly since I do believe it is perfectly legal to send every byte in a packet on its own. Apache HTTP as well as Tomcat work perfectly well with single-byte packets.

Maybe Jean Francois (or others) from the Grizzly project can add some insights to this. I will post a link to this thread to the developer-list of Glassfish.

Now back to your original posting: You've written that you are using a socket to send the request. If your problem is related to sending your request byte by byte you should consider sending complete lines instead. I guess this would be a viable workaround for the time being. It would also reduce network traffic and should be faster than sending single bytes.

--
Wolfram Rittmeyer

Message was edited by: writtmeyer

jfarcand
Offline
Joined: 2003-06-10
Points: 0

Looks like the email aren't added to this thread
===================================

-------- Original Message --------
Subject: Re: Accessing a servlet url without a web browser
Date: Mon, 21 Apr 2008 10:58:09 -0400
From: Jeanfrancois Arcand
Reply-To: users@glassfish.dev.java.net
To: users@glassfish.dev.java.net
References: <28499586.280461208711593005.JavaMail.tomcat@sdcst12.sjc.collab.net>

Hi,

just to recap. You star GlassFish v2, open a telnet session and try to
get access to your Servlet, right? That should work with v2 (v3 is
broken in that particular scenario). Now reading the email thread, you
seems to have issues with v2, right?

Can you edit ${glassfish.home}/domains/domain1/config/domain.xml and
remove the following like:

restart GlassFish and test again? Not that if you use telnet you need to
type fast the request line as if the bytes are sent to Grizzly too
slowly, Grizzly will think it is a DoS and close the connection.

Thanks

-- Jeanfrancois

writtmeyer
Offline
Joined: 2006-11-17
Points: 0

Glassfish is HTTP compliant and thus serves any well formed HTTP-request. No matter whether it is issued via a browser, telnet or any application using sockets.

Could it be that you are simply omitting the space character betweeen "GET" and "/"?

See HTTP 1.1 spec 5.1 (RFC 2116) section 5.1:
Request-Line = Method SP Request-URI SP HTTP-Version CRLF

You would have to use a first line like this:

GET /MyServlet HTTP/1.1

To better understand your problem and how to reproduce the behaviour in question it would be helpful if you could post the relevant code fragment that is responsible for issuing the request to Glassfish.

--
Wolfram Rittmeyer

ruwanin84
Offline
Joined: 2008-04-08
Points: 0

Thanks.
it seems you have understood my problem. But I'm using Sun Application Server 9.1, not Glass Fish. Actually it works with JBOSS 4.2GA.

I can access any of my servlets using GET /MyServlet if deployed it in JBOSS.
But it doesnt do any response if I use SJSAS.

I hope it will work on GlassFish as you sounds. but I cant switch to GlassFish quickly as my team already uses SJSAS.
Can you please check it for SJSAS?

Thnaks
Ruwan

writtmeyer
Offline
Joined: 2006-11-17
Points: 0

Well some branding and the installer notwithstanding SJSAS 91 and Glassfish v2UR1 are actually the same. So if it doesn't work in SJSAS it will not work in Glassfish as well.

...

I've just installed JBoss and it is true. JBoss accepts even irregular formed requests (i.e. requests omitting the HTTP-version). You should be aware of the fact that your app won't work with any server other than JBoss. I suggest to correct your app so that it complies to the HTTP protocol and works regardless of the container used. Otherwise you are stuck with JBoss.

--
Wolfram Rittmeyer

ruwanin84
Offline
Joined: 2008-04-08
Points: 0

I switched to GlassFish V2.

I deployed myservlet in GlassFish which runs on port 8080
I am using windows XP and type [b]telnet localhost 8080[/b]
then it shows me a window titled Telnet localhost
But when i tried to type [b]GET /Myservlet[/b] it comes back to command prompt.( as soon as I type letter "G" it happens)

Could you please let me know a way to test this using telnet? ( I wanna verify that can i invoke myservlet atleast using telnet)

now i tested it again with JBOSS using telnet. wow! it works even without HTTP/1.1. Is this a bug in SJSAS/GlassFish or is there any security configuration to enable this?

Thanks
Ruwan

Message was edited by: ruwanin84

Message was edited by: ruwanin84

Message was edited by: ruwanin84

writtmeyer
Offline
Joined: 2006-11-17
Points: 0

You have to type

GET /Myservlet HTTP/1.1
Host: localhost
Connection: close

Note that there must be two line breaks before the server recognizes that the request has been completed.

What is missing in your request line is the HTTP/1.1 part. This part is essential.

If you want to use just one line you have to use HTTP 1.0:

GET /Myservlet HTTP/1.0

Again there are two CRLFs needed after "HTTP/1.0".

BTW: It looks like you hit a timeout when entering "GET /Myservlet". By default this is 30 seconds with Glassfish. The value for this is configured in the -element of your domain.xml.

--
Wolfram Rittmeyer

Message was edited by: writtmeyer

Message was edited by: writtmeyer