Non-HTTP servlet

          I need to support concurrent access from multiple clients using a non-HTTP protocol
          over socket connection. One way is to write my socket server and create a new
          thread for each request. But WLS forbids user-created threads from calling into
          WLS components such as EJB. So I would like to write a non-HTTP servlet so that
          the WLS servlet container will create a new thread calling into the servlet and
          have the servlet calling EJBs on this WLS created thread. But is there a way to
          plug a subclass of GenericServelt into WLS?
          Thanks,
          T Tse
          

I don't think there is a way to use non-HTTP servlet's, but still you can use WLS
          execute queue and execute threads, for example:
          ServerSocket serverSocket = new ServerSocket(...);
          for(;;) {
          new MyThread(new RequestHandler(serverSocket.accept())).start();
          class RequestHandler implements Runnable {
          Socket socket;
          public RequestHandler(Socket socket) {
          this.socket = socket;
          public void run() {
          // to see if this is executing on a WebLogic execute thread
          new Exception().printStackTrace();
          try {
          socket.close();
          } catch(Throwable whatever) {}
          class MyThread implements Schedulable, Triggerable {
          boolean done = false;
          Runnable runnable = null;
          Object sync = new Object();
          ScheduledTriggerDef std;
          public void join() throws InterruptedException {
          synchronized(sync) {
          if(!done) {
          sync.wait();
          public void run() {
               if(runnable != null) {
               runnable.run();
          public MyThread() {
          public MyThread(Runnable runnable) {
               this.runnable = runnable;
          public boolean start() {
               boolean ok = false;
               try {
               T3ServicesDef t3 = (T3ServicesDef)(new InitialContext()).lookup("weblogic.common.T3Services");
               std = t3.time().getScheduledTrigger(this, this);
               std.schedule();
               ok = true;
               } catch(NamingException ne) {
               System.out.println(ne.getMessage());
               } catch(TimeTriggerException tte) {
               System.out.println(tte.getMessage());
               return ok;
          public void trigger(Schedulable sched) {
               try {
               run();
               } catch(Throwable t) {
               System.out.println(t);
          synchronized(sync) {
          done = true;
          sync.notify();
          public long schedule(long time) {
               return done ? 0 : 1;
          ttse <[email protected]> wrote:
          > I need to support concurrent access from multiple clients using a non-HTTP protocol
          > over socket connection. One way is to write my socket server and create a new
          > thread for each request. But WLS forbids user-created threads from calling into
          > WLS components such as EJB. So I would like to write a non-HTTP servlet so that
          > the WLS servlet container will create a new thread calling into the servlet and
          > have the servlet calling EJBs on this WLS created thread. But is there a way to
          > plug a subclass of GenericServelt into WLS?
          > Thanks,
          > T Tse
          Dimitri
          

Similar Messages

  • Non-http servlet engine?

    Hi, I'm new to servlet development and I'm not sure this question has been answered here before. So I apologize if it has.
    Basically I want to have an integrated server that can accept both http and non-http requests. So my initial thought was to write an HttpServlet and a GenericServlet. Then I googled for clues on how to implement that and found from the JavaRanch website http://faq.javaranch.com/java/ServletsFaq#otherProtocols that this task could be a daunting one because that'd imply that I have to write a new servlet engine.
    So my question is, is this true in your expert opinion? And, if the custom non-http protocol has a similar syntax as http (e.g. RTSP), is it possible to just extend the http servlet engine to support it? And would that be doable without much effort?
    Thanks,
    Liang.

    Would you actually need the entire servlet system for the new protocol? For your typical simple request/reply protocol you'd normally:
    Create a server socket.
    When a connection arrives, start a thread to service it.
    In the service thread, read and parse request.
    Send reply.
    Close socket, exit thread.
    A servlet system adds a bunch of stuff to that: a layer that allows you to configure pluggable request handlers; methdod-specific functions (POST -> doPost()); a ServletRequest object; etc. Are those things relevant to the new protocol? Do you have requests with URL-like things in the header, allowing routing requests to different servlets? Do you plan to have lots of servlets for the protocol (one servlet -> no much point in XML-configurable request routing)?
    I'd hope that I wouldn't need to implement a configurable request routing infrastructure. It's a lot of work if it's not really needed. Just write a socket server. If you have an associated web server (e.g. HTML pages from which the user starts RTSP requests) you can even run the socket server inside the servlet container if that helps.

  • Non-http servlet without headers

    I would like to create a servlet that does not respond to web requests, but to invocations by client sockets (on port 80).
    It all goes well, but even if I use a simple Servlet implementation, the web server wraps the response into a http response, and adds headers, which is unnecessary at all times. How can I avoid this?
    I use JBoss/Tomcat for container.

    Hi,
              import java.io.*;
              import javax.servlet.*;
              public class Helloservlet extends GenericServlet {
              public void service(ServletRequest req,ServletResponse res) throws
              ServletException,IOException {
              res.SetcontentType("text/html");
              PrintWriter pw = new PrintWriter();
              pw.println("<b>HelloWorld"); pw.close();
              The above example code for GenericServlet that is not specific to the http.
              Regards
              Anilkumar kari

  • Non-HTTP(S) Servlets

    I'd like to use servlets to provide services over a non-HTTP protocol (e.g. FTP, NNTP, SMTP, etc.). The existence of the Servlet -> GenericServlet -> HTTPServlet hierarchy suggests this is supposed to be possible but I'm not sure how to do it. The main problem I see is getting my servlet container to know what protocol (IP port) I want to use.
    So, are non-HTTP servlets supposed provide their own logic to set up a socket listener in the Servlet.init() method, manage their own thread pool, and dispatch requests to servlet instances as they are received? Or, is there some service provider API I can use to plug a non-HTTP service into my servlet container?
    BTW, I'd like to do this in a J2EE v1.3 server.
    Thanks, Dave

    I'd like to use servlets to provide services over a
    non-HTTP protocol (e.g. FTP, NNTP, SMTP, etc.)My first reaction would be "don't".
    In an HTTP request, there is a bunch of headers, which the servlet container uses to decide which servlet it will invoke. There are no such headers in e.g. FTP. Even if you manage to subclass Servlet to FTPServlet, the web server doesn't know how that FTP requests should be routed to that servlet.
    The piece of code that listens to port 80 etc really wants to see "GET", "POST" etc plus an URL on the first line of incoming data. That code won't respond well to seeing SMTP's "HELO".
    That being said, you can put such protocols in a web server or app server. Write a thread that creates a server socket for the appropriate port and then sits in accept(). When a connection comes in, it starts a new per-client thread which talks SMTP or whatever over the incoming socket. Pretty basic client/server socket programming.
    Also, to me, the servlet model appears inappropriate for FTP et al: a servlet services one request, then exits. FTP, NNTP and SMTP are all more like a discussion than request-reply.
    In theory, it would be possible to fashion e.g. an SMTP server as a sort of a servlet. Instead of doGet() and such perhaps you'd have doHELO(), doMAIL_FROM(), doDATA() etc. But that seems overly complicated... Seems easier to me to do simply:
        while (true)
            read socket input a line at a time;
            if (in data mode) {
                check for end-of-message;
                append to string buffer;
            } else {
                tokenize it;
                obey the incoming command;
        }Maybe if you really want to use the servlet model, write a Servlet-like class that has a doCommand() method and make the "obey the incoming command" bit above call that. I'm not sure how much that buys, though. There are enough small differences in things like command tokenizing to make code reuse in the various protocol "servlets" difficult.
    Btw, FTP in particular is an incredibly messy protocol. Implement that one only if you absolutely must, and even then crib some existing public domain implementation as a base. Active/passive, separate command/data channels, a wide range of buggy FTP clients, security difficult to get right, ... ouch...

  • Using Servlet for non HTTP purpose

    Hi,
    I have a requirement where I require tomcat to serve a non http request. Is there a way?

    The HTTP protocol begins with a line like:
    GET /some/thing HTTP/1.0
    Tomcat uses the "/some/thing" to find out to which servlet to give the request.
    If your protocol doesn't have that line, Tomcat is going to have a hard time knowing what to do with the request.
    You could write a thread that opens a ServerSocket, accepts incoming requests, and hands them off to a servlet-like system (perhaps even subclasses of Servlet). You could even run that thread within Tomcat. If you want/can restrict yourself to Tomcat, you may even be able to use parts of Tomcat's internals (the Service/Connector/Engine infrastructure or whatnot.) Whether this is a good approach depends on all kinds of details.

  • Maintain ViewObject state in non ADF servlet

    Hi,
    I am using a plain non ADF servlet to do few operations as explained in (Access Adf Binding Context in Servlet I am getting the page defs and iterators properly, but in an inconsistent state. When I get the current row off the viewObject from the iterator present in the page def, I am getting entirely different row rather that the one setup just before I invoke the servlet.....
    Can anyone please help me to find the way to get the proper state of the viewObject in the plain servlet.....

    AS long as you don't set up the right context in your servlet you can access the iterators, but you do so in an other context (like you were an other user). Follow http://www.oracle.com/technetwork/indexes/samplecode/jdeveloper-adf-sample-522118.html and look for the sample
    Sharing ADF context with a Servlet     2011-04-27     This code demonstrates how a Servlet within an application can share the same data control context (frame) as the underlying UI pages and Task Flows within that application. This approach is useful when you are creating integrated applications where servlets are leveraged to add functionality to the application such as AJAX calls or email generation.which shows how to pass the context to your servlet.
    Timo

  • Calling non standard servlet methods

    How can we call the non standard servlet methods like OPTIONS, HEAD, TRACE, etc.? Like to call the GET method of the servlet located on server xyz from some HTML page, we write the HTML form as follows :
    <form name="frmname" action="http://xyz.com/servlet/MyServlet" "method=get">
    So what should we write to call the other methods?
    Ankit.

    You can't do it directly from HTML, you need to open a connection over HTTP and then send the appropriate HTTP request. Not all web servers support these methods.

  • Non https business card?

    Is there some way to have a non-https business card URL? I'd like to point to my SDN business card from YouTube, but it only allows http:
    Suggestions welcome

    Hi,
    http://www.sdn.sap.com:80/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=vqbhn9wvrj4%3d
    or make a short version via tinyurl.
    Eddy
    PS. Which type of SDN Ubergeek/BPX suit are <a href="/people/eddy.declercq/blog/2007/05/14/which-type-of-sdn-ubergeekbpx-suit-are-you">you</a>?
    Deadline: June 15th

  • How can i send xml file with a http servlet request

    Hi
    Please tell me how can I send a xml file into http servlet request.
    I have a servlet(action) java file.From this servlet I have generate a xml file. Now I need to send that xml file to another servlet with http servlet request object.
    Dave.

    When you say you have generated an XML file what do you mean?
    Is it a file stored on disk? Then pass the file path as a string to the servlet.
    Is it stored in memory as an object? The pass a reference to the object to the servlet.
    Or are you asking how to communicate between servlets?
    Look in the JavaDocs for the RequestDispatcher class. You can use this class to forward the request to another servlet. Data can be passes using the RequestDispatcher by storing it as attributes using the request getAttribute and setAttribute methods. Also described in the JavaDOcs.
    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html

  • Can't save non http bookmarks in firefox

    Can't save non http bookmarks in firefox
    Amongst standard website favourites saved on my IE toolbar i have several html documents/pages of my own making. These obviously begin with a non-http address.
    Examples are pages that contain an array of favourite webcams on a single page, or a page that opens up several related sports sites each in their own tab, or a stormchasing swathe of tabbed windows covering live video chase, weather radar, emergency service scanners etc. etc.
    An address would take the format on the lines of
    "C:\Documents and Settings\USERNAME\My Documents\Football Results and Tables\UK.html"
    Firefox insists on adding 'http' before the C:\ (plus unlike IE it also adds the %20 for spaces.)
    Can anyone help to to get FF to accept a favourite that is not a website.

    I just verified that it still works for me in Firefox 18.0, using the "star" in the Location Bar.
    '''Try the Firefox SafeMode''' to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    [https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode#w_safe-mode-window_2 Troubleshoot Firefox issues using Firefox SafeMode]
    When in Safe Mode... <br />
    * The status of plug-ins is not affected.
    * Custom preferences are not affected.
    * All extensions are disabled.
    * The default theme is used, without a persona.
    * userChrome.css and userContent.css are ignored.
    * The default toolbar layout is used.
    * The JIT Javascript compiler is disabled.
    * Hardware acceleration is disabled.
    * You can open the Firefox 15.0+ SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    '''''If it is good in the Firefox SafeMode''''', your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes
    ''When you figure out what is causing that, please let us know. It might help other user's who have that problem.''

  • Where is NetFramework 4.5 Non-HTTP Activation?

    Hi,
    The scenario is the following:
    SCCM 2012 R2 over Windows 2012 R2 Std.
    The following article: http://technet.microsoft.com/en-us/library/gg682077.aspx#BKMK_Win2k12SiteSystemPrereqs states the following for Out of Band Service Point:
    NetFramework 4.5.
    HTTP Activation
    Non-HTTP Activation
    When I want to install Non-HTTP Activation for NetFramework 4.5, I get the following options:
    there is not Non-HTTP Activation checkbox under NetFramework 4.5.
    The question is:
    How to install Non-HTTP Activation for NetFramework 4.5 on Windows 2012 R2?
    Thanks in advance!

    Gerry should be right. See the feature and role list.
    http://blogs.technet.com/b/canitpro/archive/2013/04/23/windows_2d00_server_2d00_2012_2d00_roles_2d00_features.aspx
    Juke Chou
    TechNet Community Support

  • Resolving non http urls in JSP

    When I include an html hyperlink in my JSP as follows :
    Yahoo
    then the hyperlink on the web page points to
    http://www.yahoo.com
    However if I write the hyperlink as
    Yahoo
    then the hyperlink on the web page is wrongly created as
    http://<hostname>/www.yahoo.com
    This seems to be an issue with the JSP engine. I am using weblogic.
    Is there any way to resolve the non http urls?

    This has nothing to do with the JSP engine.
    <a href="www.yahoo.com">Yahoo</a> IS not a JSP tag and is not touched by the JSP engine.
    The problem you have is just your WEBBROWSER interpreting the url wrongly mainly becasue you have forgotten to provided the protocol your webbrowser has to use.

  • HTTP Servlet call

    Hi all,
    I have a BPM scenario where i have several conditional branches, and in one of the branch i have to make a HTTP Servlet call via HTTP adapter and pass some values from the incoming message in the HTTP post.
    Is this just like a normal HTTP adapter call or HTTP servlet is something diffrent from a normal adapter call?
    anybody has done similar HTTP servlet calls ? aplease share your thoughts.
    Thanks

    Hi,
    Its same to the normal HTTP Call but at the BPM you meight need to give conditions as you indicated...you give conditions in the Control step of BPM
    Amaresh

  • Non-HTTP(non-web) socket connection

    how do i setup non-HTTP(non-web) socket connection on my nokia 5235? please help...wanna whatsapp so badly

    Menu » Settings » Connectivity » Settings » Network destination » Internet
    Is that set correctly? Which network operator do you use? Because some operator in different countries with different settings, do not forget to mention your country, as well.

  • HTTPS Servlet requests

              After installing service pack 9 from WL5.1, HTTPS servlet requests result in the
              browser returning a server error. Issue 41888 of sp9 seems to address this. We
              were previously running service pack 6 and didn't experience this problem. Any
              ideas?
              

    Have you installed SP9 properly?
              I just tried accessing example servlets on Https protocol and i don't see any
              errors.
              Could you tell us what problems you are facing? Any test case?
              Kumar
              Darren Collins wrote:
              > After installing service pack 9 from WL5.1, HTTPS servlet requests result in the
              > browser returning a server error. Issue 41888 of sp9 seems to address this. We
              > were previously running service pack 6 and didn't experience this problem. Any
              > ideas?
              

Maybe you are looking for

  • Error while installing programs

    Log file in %temp% folder from C++ 2008 redistributable the log is the end part the forum would not let me post the whole log dd_vcredistMSI2F90.txt MSI (s) (DC:A0) [19:02:56:287]: Executing op: ActionStart(Name=RemoveODBC,Description=Removing ODBC c

  • What's the better order to install OEM + AS + DB

    Hi everbody. What's the better order to install on RHEL4 Update2: - Enterprise Manager Control Grid (10gR2) - Database (10gR2) - Application Server (10gR3) And about the $ORACLE_HOME?? How to? Each instalation have a separate $ORACLE_HOME?? Tks!

  • Time to Retire my ibook?

    My 2003 ibook works well - sort of: Only one speaker now works. Every so often one of the usb ports decides its going to take some time out. And my battery currently lasts for about 20 minutes before the machine shuts down - often without warning. Wh

  • Presentation Services Error

    Hi All, I have installed and configured OBIEE on Windows 2003 Server as per the document. On opening Presentation Services I am getting "Page cannot be displayed" error message. All the required services are running in windows services. I have chosen

  • EPS not opening in right program anymore

    ...And then even I run into something unexpected: I'm running Tiger with CS3. With that I save Photoshop CMYK images as EPS. Illustrator material that needs to be placed in a DTP program I save as CS3 EPS. Material that needs to be plotted on a vinyl