ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

simple servlet development on iseries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • simple servlet development on iseries

    Hi, i want to develop a simple servlet application on the iseries, basically to upload pictures to the iseries and display them back. I downloaded a book that explains servlet development but it uses visualage for java which i don't have. Our iseries came with websphere rational web developer.

    Can i use this to develop servlets? What perspective in the eclipse editor should i use? What type of project should i create? I really need some documentation that is websphere oriented, a simple hello world that teaches me how to upload to a directory on the iseries will do.

  • #2
    Re: simple servlet development on iseries

    Hey fjleon,

    I use websphere to create .jsp webpages. They act as a servlet in and of themselves. The nice thing about JSP's are that they are just java code invjected into html, but...you don't have to have html at all. You can just have something call the jsp and it will perform the code for you.

    Are you going to have a user interface for uploading or is this an automatic action from one directory to another?? I'll help you out as best I can. You will want to start in a web perspective.

    Do you have a local application server set up in websphere yet? This is important for testing.
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #3
      Re: simple servlet development on iseries

      I don't like jsp's that much, i prefer to separate the code from the presentation layer. I did my pregrad thesis on just servlets and freemarker to handle the visuals. So i basically that the logic behind the servlets and dispatched the presentation to freemarker's templates.

      Anyway, let's try making a simple servlet work. I used the web perspective, and created a "dynamic web page project". I saw a servlet subfolder of some sort, and created a servlet called "hola mundo", which basically prints hello word on the doGet method.

      So, after this i made a simple index.html which just redirects to /holamundo, but it doesn't work, i get the error that No target servlet configured for uri: /holamundo but in the web file i have this:

      <servlet-mapping>
      <servlet-name>holamundo</servlet-name>
      <url-pattern>/holamundo</url-pattern>
      </servlet-mapping>

      My plan is to use apache's fileupload control just like i did in my thesis. I would also need to be able to create directories and subdirectories, but that's file permissions and i will work on that later.

      So i don't know what i am doing wrong. Thanks in advance

      Comment


      • #4
        Re: simple servlet development on iseries

        Check out this link. This might help you a bit...if you need more just let me know and I'll see what I can dig up

        http://edocs.bea.com/wls/docs61/webapp/components.html


        Scratch that above....


        Try this from IBM...I think you need to add a .jsp behind like this..

        <url-pattern>/holamundo.jsp</url-pattern>

        http://publib.boulder.ibm.com/infoce...web_webxf.html

        http://publib.boulder.ibm.com/infoce...web_webxf.html
        Last edited by bryce4president; November 14, 2007, 08:47 AM.
        Your future President
        Bryce

        ---------------------------------------------
        http://www.bravobryce.com

        Comment


        • #5
          Re: simple servlet development on iseries

          What happens when you try to directly invoke the servlet from your web browser?
          Did you configure the test server in websphere to run the pages on your local machine?

          Predictions are usually difficult, especially about the future. ~Yogi Berra

          Vertical Software Systems
          VSS.biz

          Comment


          • #6
            Re: simple servlet development on iseries

            jsp's are for jsp not for servlets. There are methods to map servlets to jsp's but i don't know much about them, i just get a stack trace telling me it can't find the jsp file.

            Comment


            • #7
              Re: simple servlet development on iseries

              a jsp is a servlet.

              You need to make sure the servlet is in your WebContent folder. That is the root directory for the project.

              kpmac, This is what my path looks like...




              its the port/project_name/jsp_page

              If there isn't any html code on the jsp then it will still execute. I believe that it just goes to a white screen if you don't have any errors. If you do have an error the browser will tell you of course.
              Last edited by bryce4president; November 14, 2007, 12:40 PM.
              Your future President
              Bryce

              ---------------------------------------------
              http://www.bravobryce.com

              Comment


              • #8
                Re: simple servlet development on iseries

                When a JSP is comiled on the server it is converted to a servlet. However, in Model 2 architecture the servlet acts as a controller and decides which view (jsp) to pass the request to. In Model 2 design your servlet should house all of your business logic, database connections . . . and your jsp should be used as the presentation layer only. A jsp should not contain java business logic and a servlet should contain very little or no HTML.



                or a little bit bmore info

                Last edited by kpmac; November 14, 2007, 12:53 PM.
                Predictions are usually difficult, especially about the future. ~Yogi Berra

                Vertical Software Systems
                VSS.biz

                Comment


                • #9
                  Re: simple servlet development on iseries

                  Oh that Model 2 architecture. That gets in the way of all the fun of a great code mash up. You pretty boy coders spend so much time designing everything. What's the fun in that? Direction?

                  So just plop a huge pile of java code into a jsp file and when you compile it on the server....

                  *TADA!* a servlet. No fuss, no muss. Just need a way to invoke it, that should be the easy part

                  Or maybe all my code mashing has mashed my brain...
                  Your future President
                  Bryce

                  ---------------------------------------------
                  http://www.bravobryce.com

                  Comment


                  • #10
                    Re: simple servlet development on iseries

                    Dumb websphere. I was pretty sure i was trying http://localhostort/pruebaservlet/holamundo, but it kept saying it wasn't mapped or whatever. However, the index.html was loading fine. I erased everything and started again.

                    Now, can anyone explain how to make the iseries use it? I have read that i export it to a EAR, but how do i upload and set the path on the iseries?

                    Comment


                    • #11
                      Re: simple servlet development on iseries

                      You are using Websphere Application Server on the iSeries as well correct??
                      Your future President
                      Bryce

                      ---------------------------------------------
                      http://www.bravobryce.com

                      Comment


                      • #12
                        Re: simple servlet development on iseries

                        Yes, according to what i have read, this should be a drop in replacement, there should be some interface to upload the ear like tomcat has, or maybe just copy the file to a windows share or something. I am trying the built in components next, maybe it already has a fileupload component...

                        Comment


                        • #13
                          Re: simple servlet development on iseries

                          TO EXPORT AN EAR:

                          -Open the Project Explorer pane, click on Dynamic Web Projects, and then right click on your project name.
                          -Find 'Export' on the popup menu. It will expand to the right and click on 'Export' there.
                          -Then click EAR file from the list and click Next.
                          -Then you need to name your EAR project. Do not add a file extension like .ear because it will do it for you.
                          -Then you need to choose a destination. Click the browse button and save it to your desktop or where ever you want.
                          -Make sure that you check all three check boxes, it makes life simple. Then click Finish

                          Now you have the EAR file on your desktop.

                          Now you need to open up the Remote Systems Explorer in Websphere, or what ever utility you use to upload to your IFS. You will be able to just do a copy and paste in RSE. This is how I do it so I'll walk you through it.

                          Once you have the RSE open you need to click your server obviously. This path I give you is mine, but I'm sure that it will be almost identical to what you need to do as well...
                          Its quite a ways in there...

                          IFS Files/Root file system/QIBM/UserData/WebSphere/AppServer/V6/Base/Profiles/WAS60SVR/installableApps/

                          WAS60SVR is the name of the server profile. Yours might be different. Then once you have it expanded out go back to the top and search your Local directory until you find it on your desktop. Something like this...

                          Local/Local Files/Drives/C:\/Documents and Settings/yourprofile/Desktop/YourEar.ear

                          Copy your ear file. Then scroll down to the Installable Apps folder and paste. It will automatically upload it in there.


                          Websphere has an admin console. To get to it you would type something like...



                          Then i think you use your iSeries name and password, that's what mine is. I didn't set the server up, but I'm pretty sure that's how it authenticates. If you get to the admin console let me know.


                          If you need some Admn console help just let me know and I'll try to write another walk through.
                          Your future President
                          Bryce

                          ---------------------------------------------
                          http://www.bravobryce.com

                          Comment


                          • #14
                            Re: simple servlet development on iseries

                            I don't seem to be able to export to an EAR. I get the error message: the project 'pruebaservlet' is not an EAR project. I created it as a dynamic web project. Is there a way i can convert it?

                            Comment


                            • #15
                              Re: simple servlet development on iseries

                              When you created the project I think you needed to have the check box marked with a check in it that says.... Add module to an EAR project.

                              When you right click on Dynamic Web Projects in the Project Explorer you select New -> Dynamic Web Project

                              When the 'New Dynamic Web Project' dialog box comes up you need to click on the 'Show Advanced >>' button. Under that you will see the option I mentioned above.
                              Your future President
                              Bryce

                              ---------------------------------------------
                              http://www.bravobryce.com

                              Comment

                              Working...
                              X