Best Practice for Servlets

I guess I'm asking for most peoples' input on what I'm planning to do here ....
Here's what I want to do, and know a bit about.
o I want to make a servlet that serves only XML.
o After that, I want to transform the XML into web pages, RSS feeds etc.. using XSLT.
Here's what I'm not so sure about...
o How should I implement the interface to the web-based aspects? Should the servlet be coded to display HTML pages on "GET" requests? Or should I use a pile of HTML files to make forms?
o What do I use to perform the XSLT transformations? Where should the set of solutions be placed relative to my servlet? Would a user then access this solution rather than the servlet itself?
o How do I code the servlet on one machine, and then test it on another without breaking the libraries? How do I set up any libraries I might have to use (like for XSLT transformations) on the server?
Any other advice here? I'm sure this is done often, but I can't find a resource that explains the best practices for it all.
I know this sounds like a lot of stupid questions. I've had lots of programs working with Java before, but I'm at a loss as to how I'm supposed to package libraries I use in my programs - moreso with a servlet. To make matters worse, I plan on using MySQL as the database.
If there's some wizard on the forums here who's willing to say more than just "RTFM" (of which there is none to answer my questions together as one), I'd be very very happy ":^)

Let me re-pose my question so as to be specific
enough to not be picked apart in my answer.
I want to FIRST AND FOREMOST, create a servlet that
serves up XML based on parameters given to it (how?
who cares.).What does "serves up XML" mean?
Let's be precise. Do you intend the servlet to send the XML back to the client? Or is the XML an intermediate step in your processing? (Yes, it matters.)
Then, I want to create interfaces (HTML, RSS,
boogledeedoo) to this XML data by having either JSP,
another servlet or insert something else here,
transform the XML into whatever the desired format
is."interface" is a loaded term in Java. What do you mean by it?
>
My assumption is that I'll make the servlet that is
capable of outputting my desired XML data and then
create another servlet that will poke it for data as
needed to transform the XML into HTML. This servlet
would also likely serve as the web site itself and
would manage user logins etc...(persistance yaddy
yadda)You're not thinking about this properly.
"yadda yadda" == muddled thinking.
My other assumption is that I'll make another servlet
that will poke the XML servlet and transform that
into RSS or anything else I can dream up.How does "poke the XML servlet" fit into the request/response protocol that is HTTP? Please explain.
-=-!REASONING!-=-
Previously, when I was working with PHP, I liked to
make scripts that would display interfaces and post
to themselves. OK, now I see. "interface" == GUI in a browser to you. Very good.
You can create a JSP that is an interface. You can have that JSP submit the HTTP POST or GET request to itself. No problem there, as long as "itself" knows what to do with the request.
It was a nice way of creating a
complete little package. Everything for one function
was encapsulated nicely under one roof. No excessive
HTML files all over the place to nurture.A simple problem, a simple solution. You can do that with a JSP.
Look. Part of my inability to describe this well is
because I DO feel like I'm in a lot of directions at
once. Or you don't understand the technology very well.
But I have to be in order to pull together
some sort of plan for myself. I understand many
concepts and have just finished studying object
oriented design etc..."Just finished"? How long did it take?
I know things about how Tomcat does connection
pooling for SQL connections.Great. Not much to understand there. It's harder to figure out how to do n-tier apps with more than one page well.
I do know how to use Google, probably a lot better
than most. But rest assured, I've yet to find a
little guide as complete as any of the "LAMP" books
there are out there. Which by the way, I have never
purchased.That's because Java Enterprise Edition isn't intended for little problems. LAMP is. Maybe the limitation is that you are used to "little" problems and not bigger ones.
If JEE seems scattered and complex, it's because it is. It encompasses more than LAMP.
I'm confident in good guidance, and not a heartfelt
smackdown. I'm still waiting for some clear suggestions.I gave you one, you just didn't know it: go read about Spring.
http://www.springframework.org
It'll help you structure complex apps from the user interface to the database in the back.
You're welcome.
%

Similar Messages

  • Best practice for Servlet EJB integration

              I'm wondering what the best practice is for Servlet EJB integration in terms of
              caching the home and remote objects. My understanding is that the Home object
              is threadsafe and could therefore be cached as an attribute of the Servlet. This
              would remove the need for a JNDI lookup for each request. Similarly caching the
              ProxyObject would yield further savings. However, I have noticed that most examples
              don't use either of these practices. Why not?
              Thanks in advance,
              Geordie
              

    This has been answered repeatedly. WL allows you to cache JNDI context
              objects, ejb homes and remotes without any problems. (EJB remote interfaces
              must only be used by one thread at a time, but that requirement is provided
              by the EJB spec itself.)
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Geordie" <[email protected]> wrote in message
              news:3af9579f$[email protected]..
              >
              > I'm wondering what the best practice is for Servlet EJB integration in
              terms of
              > caching the home and remote objects. My understanding is that the Home
              object
              > is threadsafe and could therefore be cached as an attribute of the
              Servlet. This
              > would remove the need for a JNDI lookup for each request. Similarly
              caching the
              > ProxyObject would yield further savings. However, I have noticed that
              most examples
              > don't use either of these practices. Why not?
              >
              > Thanks in advance,
              > Geordie
              

  • Best Practice For Referencing JPEG Path Using Servlets To Prepare HTML IMG

    I am migrating a legacy app from Tomcat 5 to Weblogic 11g (10.3). In the legacy app, servlets write HTML that uses relative paths for <IMG src="../images/img.jpeg"> and <script src="../javascript/js.js">. The app is deployed as an exploded archive. Unfortunately, none of the images or script are being loaded. I've tried using http://serverIP:portNum/contextName/images/img.jpeg"> but it doesn't work. I've also checked to get the name of the context in the servlet and it's the root context. Could it have something to do with me having to append .war onto the application when I deploy it? Would it help if I deployed it as a war inside an ear? Basically, I want some best practices for doing this on Weblogic 11g. There are a lot of images and javascript and I'm really hoping they don't have to be inserted using ClassLoader.getResourceAsStream()... thank you.

    Best Practice:
    1. Move Static files like images, css, java scripts to a web server infrastructure if available.
    2. If this is not your case, then please send your directory information how you have packaged your EAR. I can advice :)

  • Best Practices for Defining NDS Java Projects...

    We are doing a Proof of Concept on using NDS to develop non-SAP Java applications.  We are attempting to determine if we can replace our current Java development tools with NDS/WAS.
    We are struggling with SAP's terminology and "plumbing" for setting up/defining Java projects.  For example, what is and when do you define Tracks, Software Components, Development Components, etc.  All of these terms are totally foreign to us and do not relate to our current Java environment (at least not that we can see).  We are also struggling with how the DTR and activities tie in to those components.
    If any one has defined best practices for setting up Java projects or has struggled with and overcome these same issues, please provide us with some guidance.  This is a very frustrating and time-consuming issue for us.
    Thank you!!

    Hi Peggy,
    In Component Model we divide software projects into small components.Components can use other components in well defined manner.
    A development object is a part of a component that can be changed or developed in some way; it provides the component with a certain part of its functionality. A development object may be a Java class, a Web Dynpro view, a table definition, a JSP page, and so on. Development objects are always stored as “sources” in a repository.
    A development component can be defined as a frame shared by a number of objects, which are part of the software.
    Software components combine components (DCs) to larger units for delivery and deployment.
    A track comprises configurations and runtime systems required for developing software component versions.It ensures stable states of deliverables used by subsequent tracks.
    The Design Time Repository is for versioning source code management. Distributed development of software in teams. Transport and replication of sources.
    You can also find lot of support in SDN for the above concepts with tutorials.
    Refer this Link for a overview on Java development Infrastructure(JDI)
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/java development infrastructure jdi overview.pdf
    To understand further
    Working with Net Weaver Development Infrastructure :
    http://help.sap.com/saphelp_nw04/helpdata/en/03/f6bc3d42f46c33e10000000a11405a/content.htm
    In the above link you can find all the concepts clearly explained.You can also find the required tutorials for development.
    Regards,
    Vijith

  • Best practice for declaring and initializing String?

    What is the best practice for the way Strings are declared in a class?
    Should it be
    private String strHello = "";
    or should I have the initialization in the constructors?

    The servlet constructor is usually called once, when the servlet is first accessed. But then again maybe something else happens, google servlet life cycle if you must know.
    But let's take a step backwards here. It seems like you are trying to put fields into servlets. Don't do that. When two users fetch the servlet's URL at the same time, the fields are shared between the two hits. If you store something like HTTP parameters in the fields, the two hits' parameters will get mangled. The hits can end up seeing each other's parameter values.
    The best way is not to have fields in servlets. (Except maybe "static final" constants, sometimes rarely something else.) Many concurrency worries go away, servlet life cycle worries go away, servlet constructors go away, init() usually goes away.

  • What are best practice for packaging and deploying j2EE apps to iAS?

    We've been running a set of J2EE applications on a pair of iAS SP1b for about a year and it has been quite stable.
    Recently however we have had a number of LDAP issues, particularly when registering and unregistering applications (registering ear files sometimes fails 1st time but may work 2nd time). Also We've noticed very occasionally that old versions of classes sometimes find their way onto our machines.
    What is considered to be best practice in terms of packaging and deployment, specifically:
    1) Packaging - using the deployTool that comes with iAS6 SP1b to package is a big manual task, especially when you have 200+ jsp files. Are people out there using this or are they scripting it with a build tool such as Ant?
    2) Deploying an existing application to multiple iAS's. Are you guys unregistering old application then reregistering new application? Are you shutting down iAS whilst doing the deployment?
    3) Deploying ear files can take 5 to 10 mins, is this normal?
    4) In a clustered scenario where HTTPSession is shared what are the consequences of doing deployments to data stored in session?
    thanks in asvance for your replies
    Owen

    You may want to consider upgrading your application server environment to a newer service pack. There are numerous enhancements involving the deployment tool and run time layout of your application that make clear where you're application is loading its files from.
    If you've at a long running application server environment, with lots of deployments under your belt, you might start to notice slow downs in deployment and kjs start time. Generally this is due to garbage collecting in your iAS registry.
    You can do several things to resolve this. The most complete solution is to reinstall the application server. This will guarantee a clean ldap registry. Of course you've got to restablish your configurations and redeploy your applications. When done, backup your application server install space with the application server and directory server off. You can use this backup to return to a known configuation at some future time.
    For the second method: <B>BE CAREFUL - BACKUP FIRST</B>
    There is a more exhaustive solution that involves examining your deployed components to determine the active GUIDS. You then search the NameTrans section of the registry searching for Applogic Servlet *, and Bean * entries that represent your previously deployed components but are represented in the set of deployed GUIDs. Record these older GUIDs, remove them from ClassImp and ClassDef. Finally remove the older entries from NameTrans.
    Best practices for deployment depend on your particular environmental needs. Many people utilize ANT as a build tool. In later versions of the application server, complete ANT scripts are included that address compiling, assembly and deployment. Ant 1.4 includes iAS specific targets and general J2EE targets. There are iAS specific targets that can be utilized with the 1.3 version. Specialized build targets are not required however to deploy to iAS.
    Newer versions of the deployment tool allow you to specify that JSPs are not to be registered automatically. This can be significant if deployment times lag. Registered JSP's however benefit more fully from the services that iAS offers.
    2) In general it is better to undeploy then redeploy. However, if you know that you're not changing GUIDs, recreating an existing application with new GUIDs, or removing registered components, you may avoid the undeploy phase.
    If you shut down the KJS processes during deployment you can eliminate some addition workload on the LDAP server which really gets pounded during deployment. This is because the KJS processes detect changes and do registry loads to repopulate their caches. This can happen many times during a deployment and does not provide any benefit.
    3) Deploying can be a lengthy process. There have been improvements in that performance from service pack to service pack but unfortunately you wont see dramatic drops in deployment times.
    One thing you can do to reduce deployment times is to understand the type of deployment. If you have not manipulated your deployment descriptors in any way, then there is no need to deploy. Simply drop your newer bits in to the run time space of the application server. In later service packs this means exploding the package (ear,war, or jar) in to the appropriate subdirectory of the APPS directory.
    4) If you've changed the classes of objects that have been placed in HTTPSession, you may find that you can no longer utilize those objects. For that reason, it is suggested that objects placed in session be kept as simple as possible in order to minimize this effect. In general however, is not a good idea to change a web application during the life span of a session.

  • Best practice for loading config params for web services in BEA

    Hello all.
    I have deployed a web service using a java class as back end.
    I want to read in config values (like init-params for servlets in web.xml). What
    is the best practice for doing this in BEA framework? I am not sure how to use
    the web.xml file in WAR file since I do not know how the name of the underlying
    servlet.
    Any useful pointers will be very much appreciated.
    Thank you.

    It doesnt matter whether the service is invoked as part of your larger process or not, if it is performing any business critical operation then it should be secured.
    The idea of SOA / designing services is to have the services available so that it can be orchestrated as part of any other business process.
    Today you may have secured your parent services and tomorrow you could come up with a new service which may use one of the existing lower level services.
    If all the services are in one Application server you can make the configuration/development environment lot easier by securing them using the Gateway.
    Typical probelm with any gateway architecture is that the service is available without any security enforcement when accessed directly.
    You can enforce rules at your network layer to allow access to the App server only from Gateway.
    When you have the liberty to use OWSM or any other WS-Security products, i would stay away from any extensions. Two things to consider
    The next BPEL developer in your project may not be aware of Security extensions
    Centralizing Security enforcement will make your development and security operations as loosely coupled and addresses scalability.
    Thanks
    Ram

  • Best practice for dealing with Recordsets

    Hi all,
    I'm wondering what is best practice for dealing with data retrieved via JDBC as Recordsets without involving third part products such as Hibernate etc. I've been told to NOT use RecordSets throughout in my applications since they are taking up resources and are expensive. I'm wondering which collection type is best to convert RecordSets into. The apps I'm building are webbased using JSPs as presentation layer, beans and servlets.
    Many thanks
    Erik

    There is no requirement that DAO's have a direct mapping to Database Tables. One of the advantages of the DAO pattern is that the business layer isn't directly aware of the persistence layer. If the joined data is used in the business code as if it were an unnormalized table, then you might want to provide a DAO for the joined data. If the joined data provides a subsiduray object within some particular object, you might add the access method to the DAO for the outer object.
    eg:
    In a user permissioning system where:
    1 user has many userRoles
    1 role has many userRoles
    1 role has many rolePermissions
    1 permission has many rolePermissions
    ie. there is a many to many relationship between users and roles, and between roles and permissions.
    The administrator needs to be able to add and delete permissions for roles and roles for users, so the crud for the rolePermissions table is probably most useful in the RoleDAO, and the crud for the userRoles table in the UserDAO. DOA's also can call each other.
    During operation the system needs to be able to get all permissions for a user at login, so the UserDAO should provide a readPermissions method that does a rather complex join across the user, userRole, rolePermission and permission tables..
    Note that f the system I just described were done with LDAP, a Hierarchical database or an Object database, the userRoles and rolePermissions tables wouldn't even exist, these are RDBMS artifacts since relational databases don't understand many to many relationships. This is good reason to avoid providing DAO's that give access to those tables.

  • Best Practice For Cube Design

    All,
    First post here and was wondering if anyone out there has a best practice for cube design or optimisation. Currently have 7 Cubes that have been populated for the last 6 months and am now looking at ways of speeding up their population.
    Are there any hard and fast rules about dimensions?
    Should they be kept to a percentage of the fact table?
    When should line item dimensions be used?
    Regards
    Gary Boyle

    Hi Gary,
    Ideally the DIM tables should be 20% of the fact table and preferably less. You can check the size ratios in RSRV using the Database tables test > Database info about InfoProvider tables. Line items dimensions should be employed where the char has a large number of unique values (like 0MATERIAL, or 0CUSTOMER), so that anothe DIM ID is not created, but the SID values are used directly in the Fact Table.
    See these for more:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/10b589ad-0701-0010-0299-e5c282b7aaad
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/08f1b622-0c01-0010-618c-cb41e12c72be
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6ce7b0a4-0b01-0010-52ac-a6e813c35a84
    Hope this helps...

  • Best Practices For Portal Content Objects Transport System

    Hi All,
    I am going to make some documentation on Transport Sytem for Portal content objects in Best Practices.
    Please help in out and send me some documents related to SAP Best Practices for transport  for Portal Content Objects.
    Thanks,
    Iqbal Ahmad
    Edited by: Iqbal Ahmad on Sep 15, 2008 6:31 PM

    Hi Iqbal,
    Hope you are doing good
    Well, have a look at these links.
    http://help.sap.com/saphelp_nw04/helpdata/en/91/4931eca9ef05449bfe272289d20b37/frameset.htm
    This document, gives a detailed description.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f570c7ee-0901-0010-269b-f743aefad0db
    Hope this helps.
    Cheers,
    Sandeep Tudumu

  • SAP Best Practice For Unicode Upgrades - NetWeaver 2004s

    Team SAP,
    I have a customer that is starting to plan for a Unicode upgrade.  The question from the customer is as follows:
    What is the SAP Best Practice for Unicode Upgrades?  They will be upgrading from a BW 3.5 System to NetWeaver 2004s, and their question is ... should they:
       a) Perform the Unicode Upgrade At The Same Time As Their BW 3.5 > NetWeaver 2004s Upgrade, or
       b) Perform NetWeaver 2004s Upgrade first, and then at a later date, perform the Unicode Upgrade?
    Thank you in advance for any guidance or counsel you may be able to offer.
    -M

    Hi Michael,
    Check these links:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ee7407a0-0501-0010-81ae-e329029b1074
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7e259990-0201-0010-6085-e7c5aec5af1d
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5411d290-0201-0010-b49b-a6145fb16d15
    Bye
    Dinesh

  • Best practice for placing module

    Hello
    I have an enterprise application project, with :
    1) EJB Module
    2) Web Module .
    I want to add the hibernate jars+classes+data+servlets+utils etc...
    Should i create a new Web module for hibernate or should i add it to the existing EJB module which is my business logic ?
    What is the best practice for that?
    Thanks !

    Thanks for the reply, Jiri.
    I believe that the answer is 'yes' to both of your questions above. I do have a question about the formatting of the meta tag itself, as my main question is how do I extract the needed information from a particular CDF so that it is displayed in the <head> section located in the page template.
    I have a Region Definition for the content section of my page with a 'Title' field, which a contributor can fill in, save, and create a Contributor Data File with their own specified title. Let's also say that my page template, which formats the entire page, looks like this (rough):
    <html>
      <head>
      <title>Web page</title>
      </head>
      <body>
      <!-- placeholder for header section -->
      <!-- placeholder for content section -->
      <!-- placeholder for footer section -->
      </body>
    </html>
    What would my <meta> tag look like for the following:
      <meta property="og:title" content="Title of the content section"/>
    Let's name our templates/definitions:
    Page Template: PT_META
    Region Template: RT_META
    Region Definition: RD_META
    Contributor Data File: CDF_META
    In other words, how do I extract the information included in the Contributor Data File (as well as its metadata) for use in the Page Template? Is there some sort of Idoc Script call that can be used?
    Thank you so much,
    Josh

  • Help Please!!  Best Practices for building an NDS Project...

    We are doing a Proof of Concept on using NDS to develop non-SAP Java applications. We are attempting to determine if we can replace our current Java development tools with NDS/WAS.
    We are struggling with SAP's terminology and "plumbing" for setting up/defining Java projects. For example, what is and when do you define Tracks, Software Components, Development Components, etc. All of these terms are totally foreign to us and do not relate to our current Java environment (at least not that we can see). We are also struggling with how the DTR and activities tie in to those components.
    If any one has defined best practices for setting up Java projects or has struggled with and overcome these same issues, please provide us with some guidance. This is a very frustrating and time-consuming issue for us.
    Thank you!!

    Hello Peggy,
    this is my first post but I hope it helps you anyway.
    To learn the SAP "language" I additionally used the a SAP Presentation regarding the SAP JDI.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/java development infrastructure real world use webinar.pdf
    I think this one is quite useful as an addon to the other links for information you already got. Your name also indicates that your mother-tongue language is German. If so, the german version of the book (Java-Programming with the SAP WAS) is already available for purchase and really useful. Then, you can also use the information provided by the University of Potsdam. They have an introduction about how to setup a track in the SLD and then how to setup SCs.
    http://epic.hpi.uni-potsdam.de/nwlab/SC+Track.html
    Hope this helps...

  • Best practices for setting up users on a small office network?

    Hello,
    I am setting up a small office and am wondering what the best practices/steps are to setup/manage the admin, user logins and sharing privileges for the below setup:
    Users: 5 users on new iMacs (x3) and upgraded G4s (x2)
    Video Editing Suite: Want to connect a new iMac and a Mac Pro, on an open login (multiple users)
    All machines are to be able to connect to the network, peripherals and external hard drive. Also, I would like to setup drop boxes as well to easily share files between the computers (I was thinking of using the external harddrive for this).
    Thank you,

    Hi,
    Thanks for your posting.
    When you install AD DS in the hub or staging site, disconnect the installed domain controller, and then ship the computer to the remote site, you are disconnecting a viable domain controller from the replication topology.
    For more and detail information, please refer to:
    Best Practices for Adding Domain Controllers in Remote Sites
    http://technet.microsoft.com/en-us/library/cc794962(v=ws.10).aspx
    Regards.
    Vivian Wang

  • Best-practice for Catalog Views ? :|

    Hello community,
    A best practice question:
    The situtation: I have several product categories (110), several items in those categories (4000) and 300 end-users.    I would like to know which is the best practice for segment the catalog.   I mean, some users should only see categories 10,20 & 30.  Other users only category 80, etc.    The problem is how can I implement this ?
    My first idea is:
    1. Create 110 Procurement Catalogs (1 for every prod.category).   Each catalog should contain only its product category.
    2. Assign in my Org Model, in a user-level all the "catalogs" that the user should access.
    Do you have any idea in order to improve this ?
    Saludos desde Mexico,
    Diego

    Hi,
    Your way of doing will work, but you'll get maintenance issues (to many catalogs, and catalog link to maintain for each user).
    The other way is to built your views in CCM, and assign these views to the users, either on the roles (PFCG) or on the user (SU01). The problem is that with CCM 1.0 this is limitated, cause you'll have to assign one by one the items to each view (no dynamic or mass processes), it has been enhanced in CCM 2.0.
    My advice:
    -Challenge your customer about views, and try to limit the number of views, with for example strategic and non strategic
    -With CCM 1.0 stick to the procurement catalogs, or implement BADIs to assign items to the views (I experienced it, it works, but is quite difficult), but with a limitated number of views
    Good luck.
    Vadim

Maybe you are looking for