Multi-functional Servlet considered bad practice?

Hi,
is it considered bad practice using doGet() for fetching say a blog entry and using doPost() for saving new entries or comments?
Such as:
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
     blog.getPost(id);
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
     Post post = new Post(title, msg, category, author);
     blog.save(post);
}I like to think that this is the reasoning or at least part of the reason why doGet and doPost are separate methods.
Thank you.
Regards,
Adam

Asham wrote:
Hi,
is it considered bad practice using doGet() for fetching say a blog entry and using doPost() for saving new entries or comments?Depends on current environment and requirements. In a small hobby application you can do so. In real business I wouldn't do so, it might bite in the future if you plan to extend that servlet with more logic.
I like to think that this is the reasoning or at least part of the reason why doGet and doPost are separate methods.No, it is not. The HTTP protocol specification (1) offers several request methods, GET, POST, HEAD, PUT, DELETE, etc. The HttpServlet API (2) offers overrideable methods for each of those request methods so that you can handle it using some Java logic. A "plain vanilla" request is always GET. A form submit can be either GET or POST -generally POST is preferred as it can transfer more data and does "hide" query parameters.
(1) http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
(2) http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServlet.html

Similar Messages

  • Hi, I'm designing my 1st website and I started it in  photoshop cs5.5. I know that it's bad practice

    Hi, I'm designing my 1st website and I started it in  photoshop cs5.5. I know that it's bad practice to build with images, I learned this too late. I imported my site into Dreamweaver cs5.5 and uploaded it to my server. The problem I'm having is that I want to apply a jquery drop down menu bar but whenever I try, I get white gaps within my page. How do I convert the coding into a functioning site?*Help Please*  The URL to my site is: http://www.coriemoment.com and this is my coding:
    <html xmlns="http://www.coriemoment.com"
    <head>
    <title>The Official Corie Moment Home</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
        <div id="=container"
    <body bgcolor="#FFFFFF" leftmargin="auto" topmargin="auto" marginwidth="auto" marginheight="auto" margin:0;>
    <!-- Save for Web Slices (home.psd) -->
    <table id="Table_01" width="1281" height="768" border="0" cellpadding="0" cellspacing="0">
              <tr>
                        <td colspan="6">
                                  <img src="images/index_01.png" width="1280" height="220" alt=""></td>
                        <td>
                                  <img src="images/spacer.gif" width="1" height="220" alt=""></td>
              </tr>
              <tr>
                        <td rowspan="4">
                                  <img src="images/index_02.png" alt="" width="414" height="548"></td>
                        <td rowspan="3">
                                  <object width="564" height="423"><param name="movie" value="http://www.youtube.com/v/XbuQiJ6Sv_M?hl=en_US&version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/XbuQiJ6Sv_M?hl=en_US&version=3" type="application/x-shockwave-flash" width="564" height="423" allowscriptaccess="always" allowfullscreen="true"></embed></object></td>
                        <td colspan="3">
                                  <img src="images/index_04.png" width="255" height="89" alt=""></td>
                        <td rowspan="4">
                                  <img src="images/index_05.png" width="46" height="548" alt=""></td>
                        <td>
                                  <img src="images/spacer.gif" width="1" height="89" alt=""></td>
              </tr>
              <tr>
                        <td rowspan="2">
                                  <img src="images/video_03-07.png" width="1" height="336" alt=""></td>
                        <td rowspan="3">
                                  <img src="images/index_07.png" width="34" height="459" alt=""></td>
                        <td>
                                  <script src="http://widgets.twimg.com/j/2/widget.js"></script>
    <script>
    new TWTR.Widget({
      version: 2,
      type: 'search',
      /*put your twitter id that people use to reply to you below. Mine is mhorning. If you only want to see the Tweets that you have Tweeted, then delete the part below that says- OR to:coriemoment */
      search: 'from:coriemoment OR to:coriemoment',
       /*this is the duration in terms of seconds*/
      interval: 30000,
       /*this is the title you want on your tweets*/
      title: 'Corie Tweets',
      subject: 'Send us your comments',
       /*setting width to 'auto' will adjust the width of your tweetbox to whatever is set on your div. You can change this to something like 500px if you want*/
      width: 'auto',
      height: 212,
      theme: {
        shell: {
                 /*this will change the background color of your tweetbox. It is currently yellow*/
                background: 'body p, body img, body embed, body object, body video{opacity:1 !important}',
          /*this will change the color of the text in your background*/
                color: 'fac935'
        tweets: {
                 /*this will change the background color behind your tweets. It is currently white*/
                background: 'body p, body img, body embed, body object, body video{opacity:0.2 !important}',
           /*this will change the color of the text in your tweets. It is currently black*/
                color: '#000000',
           /*this will change the color of anything that is hyperlinked in your tweet. It is currently blue*/
                links: '#1985b5'
      features: {
        scrollbar: false,
        loop: true,
        live: true,
        behavior: 'default'
    }).render().start();
    </script></td>
                        <td>
                                  <img src="images/spacer.gif" width="1" height="302" alt=""></td>
              </tr>
              <tr>
                        <td rowspan="2">
                                  <img src="images/index_09.png" width="220" height="157" alt=""></td>
                        <td>
                                  <img src="images/spacer.gif" width="1" height="34" alt=""></td>
              </tr>
              <tr>
                        <td colspan="2">
                                  <img src="images/index_10.png" width="566" height="123" alt=""></td>
                        <td>
                                  <img src="images/spacer.gif" width="1" height="123" alt=""></td>
              </tr>
    </table>
    <!-- End Save for Web Slices -->
    </body>
    </html>

    mazz2000 wrote:
    The best way to do it is go back to PS and place the navigation area in the design, i would make it 100% of the width and then re-slice the design making sure one single slice is the whole of this navigation area.
    That would be the best way to do it while still using a table layout which in and of itself is not recommended, in large part  for this very reason.
    Every time you want to make a small change to the layout of your site, it will require re-slicing and re-generating code out of PS. You would be much better off taking the time to understand css layouts. Here is a good place to start to get the basics of css: http://www.w3schools.com/css

  • Printing Booklets to an HP Color LaserJet 9500w/Multi-Function Finisher

    I work for a private art school with a strong Graphic Arts program. WE recently purchased a Multi-function Finisher for our HP Color LaserJet 9500 hdn which has duplexing capabilities. Weve run into a road block trying to output booklets from InDesign that are saddle-stitched, folded and stapled.
    The HP support people are recommending that I take a step backwards and try outputing from MS Word. Not really an option at a school where we consider the page layout standard as Adobe InDesign.
    If anyone can shed some light on workable settings for this in CS3 please contact me at: [email protected] Many thanks.

    Answered in the Mac forum.
    In the future, if you feel the need to crosspost, please indicate that
    in your post. This is for everyone's benefit.
    Bob

  • Is this bad practice?

    Consider the follwing two classes:
    public class Widget
    public class CustomWidget extends Widget
    }Now consider another class that has a Widget class member:
    public class OrdinaryClass
      private Widget w = new Widget();
      public Widget getTheWidget()
        return w;
    }Now suppose I were to subclass OrdinaryClass as follows:
    public class SpecialClass extends OrdinaryClass
      private CustomWidget cw = new CustomWidget();
      public CustomWidget getTheWidget()  // violate LSP?
        return cw;
    }My questions are:
    1) does SpecialClass violate Liskov's Principle in that the getWidget return type has changed?
    2) if it's not in violation, is it bad practice anyway? Or is this some polymorphic trick that is not only acceptable, but very useful (and encouraged)?
    Please advise.

    A custom model was subclassd from AbstractListModel.
    One of the getter methods from ALM has a return of
    f type Object. The custom model used the same
    getter, but returned the toString() of the Object (a
    property) instead of the Object in its entirety.Given this specific class hierarchy, you're into territory for design lawyers. A list mode maintains data that's used by a JList[i/]. The contract, as a result, is fairly open, and you could define the model as maintaining string representations for an object. The purists would respond with "no, the view should decide the representation," and I'd probably agree with them.
    By comparison, the contract for a [i]java.util.List is much more explicit: you put objects into the list, and you get the same objects out. If your colleague was creating a List implementation that returned toString() of an object rather than the object itself, then your argument would have much more force.
    It seems as if changing the return type of a method
    in a subclass seems wrong, even if the new return
    type is a sub of the original return type.
    I have nothing against returning the subclass, mind
    you. Just keep the contract (i.e, the return type)
    the same.However, the "contract" is not defined just by method signature. If that were the case, then this would be a perfectly valid implementation of List.get():
    public Object get(index i)
        return new Integer(i);
    }Instead, the "contract" is defined by the class as a whole, and furthermore is defined by your application for each instance of a class that it creates (eg, "this List is used to pass strings between these two methods").

  • Is it ever bad practice to use threads?

    Hi there ppl,
    this may sound like a really silly question is it ever bad practice to use threads? I actually have never explicitly used threads and came across a simple swing application recently which used a thread in the code. Then I started to think that if ever a scenario came up where I was expected to use threads I'd have to learn something new that I should I have already known from birth, then run and hide behind the JAVA API (which is big, real big, BIGGER THAN OPRAH!!!).
    So for now I'll "synchronise my watch" (PUN INTENDED), and await the flood of replies.
    Thx already ;)

    Main Entry: 1pun
    Pronunciation: 'p&n
    Function: noun
    Etymology: perhaps from Italian puntiglio fine point,
    quibble -- more at PUNCTILIO
    : the usually humorous use of a word in such a
    way as to suggest two or more of its meanings or the
    meaning of another word similar in sound
    emphasis mine (synchronize watch vs. synchronize
    threads)...
    Ironic that it derives from "fine point, quibble."
    &para;

  • Favorite Color Laser Multi Function Printer

    Hi,
    We have four computers all running OS 10.6 connected to Airport Extreme base. Currently using Brother 5440 inkjet connected via Ethernet to the Airport. It scans from all computers, albeit with an occasional restart of the printer. We're looking to replace it (bad printerhead) with a Multi Function Laser device. I've read many reviews, etc complaining about inability to scan over the network or driver problems (HP 1312) for instance. My printer tech person recommends Canon 8350 or HP 1312. Any thoughts on the best Snow Leopard compatible Color Laser MF Printer?

    After long consideration and being fed up with issues with HP printers in he past (especially with limited functionalities with Mac OS), I bought me a Canon MP560 this summer.
    I think it's a great value for money, to refill the ink is reasonably priced (o.k., it could always be cheaper), but my most favorite feature is that I can print and scan from anywhere in the house. So far I am very pleased with both the scanning and printing results. Installation and handling of the SW suite is a child's play.
    If I had to print more I would actually look into a Laser / LED MFP... perhaps the Brother MFC-9120CN or its wireless brother MFC-9320CW, which costs actually quite a bit more.
    Unfortunately, as it seems, Canon has nothing to offer in this class of printers at reasonable prices that are also rated high.
    Just my 10 cents.

  • Using Accessor Method from Within Considered Best Practice?

    I was wondering what is considered best practice in the AS3 world regarding this topic.
    In C++ and .NET world, as well as PHP I would consider using accessor methods, instead of directly accessing the class property, bad practice due to unnecessary overhead.
    What are your thoughts in this?

    Getters and setters and bindable vars can be public, protected or private.  Which one you choose follows standard object-oriented practices.
    is just like a macro that defines a particular get/set pair.  I would only use it on vars.  Using it on a getter simply wraps the getter in another get/set pair which is wasteful.  The Flex Framework rarely uses .  Instead, we typically define get/set pairs with metadata so we can control what event fires and when.  It also saves SWF size because the compiler doesn't have to generate a long and ugly name to avoid name collisions.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Fax via Network Multi-Function Printer

    I own a HP Multi-Function device to print, scan, fax, etc. My home network is set up to PRINT wirelessly from my computer to my printer, but for some reason I am unable to FAX wirelessly. As of now I must first print the document then fax it manually, when I'd much rather skip the middle steps of printing and just fax it directly using my network. The only way I can send a fax from my computer is bypass my wireless network and plug directly into the HP printer via USB. I think if I can print wirelessly why can't I fax wirelessly too? Any suggestions?
    MacBook Pro
    Latest version of Leopard
    Time Capsule Networked Router
    No Modem
    HP All-In-One Printer/Scanner/Fax plugged into a phone line

    TC (and airport extreme) peripheral support falls into universal (ethernet) and special (usb).
    Anything that can be connected to the ethernet port will be translated through the wireless system and work just well (or not well) as it would if connected via ethernet. Devices plugged into the USB port (directly or through a hub) require special support by Apple. Apple writes drivers for these and adds a tab to the airport utility software. This used to be just printers. Currently, this is limited to printers and hard drives. MFCs go beyond the simple printing function Apple is trying to support via USB.
    In my case, I have a Brother 7820n MFC. Its designed to operate over ethernet. Plugged into the TC, this means printing, scanning, and faxing (right out the phone jack) wirelessly - from every computer in the house.
    Does your MFC offer an ethernet upgrade?

  • Wireless print server that suppports multi-function?

    I have a family member who has an HP multi-function USB only printer (can't remember the model offhand). They are looking to get a laptop soon. I was also gonna then hook them up with a wireless router for their home & DSL connection. The current HP printer is USB, but I would like to somehow make it wireless. I have used several wireless print server devices for USB printers, but none of them support the multi-functions (scan, copy, fax, etc) and simply allow you to do basic printing wirelessly. Short of buying a totally new wireless printer and/or network printer of some sort that can plug into the router & then handle all these functions wirelessly, is there possibly any wireless routers or wireless print server devices out there that will FULLY handle HP multi-function printers?
    Message Edited by mcf57 on 11-30-2009 09:12 AM
    This question was solved.
    View Solution.

    I have never heard of one.  Besides, it would cost about the same $ to get a new wireless all-in-one.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • 10.6.8 Snow Leopard loses HP multi-function scanner connection when users are switched.

    I've got 10.6.8 (Snow Leopard) installed on an iMac with a USB attached HP multi-function printer/scanner/fax.
    I've removed all HP software and got the latest HP drivers from Software Update.
    The software was able to scan appropriately using Preview and Image Capture until my wife signed onto the computer using her id.
    (She switched users and logged into her account on the same iMac.)
    Upon switching back to my user id, there was 'No scanner detected.'  I removed and re-added the printer.  No luck.
    (In fact, upon re-adding the printer, the connection just showed 'USB' instead of 'USB multi-function', and doesn't find a scanner.)
    Rebooting solves the problem (until the next time we switch users).
    Anybody have any ideas?
    Thanks,
    Jimmy

    Is it possible to run the Macgames Realmyst disc on Snow Leopard10.6.8 at 64bit?
    I believe RealMyst is a "pure" is only PowerPC.  So it doesn't matter whether you boot in 32 or 64 bit but it does matter whether you installed Rosetta on your system (optional when you installed your system) to handle the ppc code.  Even with Rosetta there's no guarantees that app will run in 10.6.8.
    Also RealMyst is for OSX.  SheepShaver is for emulating Clasic OS9 so forget about that.

  • Have an Epson workforce 600 worked fine until new router and Lion installed.  Now when I try and scan with the all in one I get a "POWER PC APPLICATIONS ARE NO LONGER SUPPORTED"  and my IMAC does not recognize that the Epson is a multi function printer.

    Installed a new router.  Installed Lion. Have an Epson Workforce 600 multi function printer.  Two problems. 
    1. I cannot get Lion to recognize that the Epson is a multi function printer.  There is no scan option on the "print/Scan" popup window.
    2. When I try and use the epson scan utility I get:  POWER PC APPLICATIONS ARE NOT LONGER SUPPORTED.
    I have tried EPSON support with no real luck as they say it is Apple upgrades that are the problem.
    Apple support was quite rude..said it was not their problem and that I should call epson.  Told the I did but it made no difference just got the same reply.
    Have no idea what to do.....seems I cannot find out which multi-function printers Lion supports. 

    daolbuzzard1 wrote:
    Epson Workforce 600 multi function printer
    Not to give you another run around, but you need new printer drivers from Epson for your printer so it works in Lion.
    Now it could be that they are working on it, or that they could have decided not to provide new drivers in order for you to force upgrade.
    The only thing a user can do is decide very carefully BEFORE upgrading to a newer Apple operating system, make sure that all their current hardware and software works and make a decision for themselves.
    Since you upgraded to Lion, you can go back to Snow Leopard and your PPC software will work.
    Do you need instructions?

  • Can someone recommend a good multi-function scanner/printer/copier that works with Mac OS 10.6.8?

    I've just purchased a Canon Image Class MF4570dn. Very disappointed to find that whatever I do I cannot get the scanner to work & the Apple support board is of no help.
    It seems like there is a conflict with OS 10.6.8 that does not let the scanner get recognized by any scanning software -- either the Mac native software in Preview or the Canon software included on CD with the box & via download from Canon's site. The Canon software is called "MF Toolbox" but for the life of me I can't get it to start without instantly crashing!
    Any suggestions of set-ups that are working with you on a similar system set-up would be much appreciated!

    This is  discouraging! I ended up trying Canon because my Macbook Pro suddenly stopped recognizing my previous HP scanner -- a MF inkjet printer.
    I have been looking at HP multi-function lasers in lieu of this faulty Canon I just returned.
    I intend to be doing very simple things with whatever MF unti I end upw ith -- no printing or scanning over the network. I'm happy to connect it directly to my computer via USB. So I'm not sure I'd experience the problems you are having.
    Maybe I should go w/ one of these Brother units? Is there anyone on this board that can attest to these machines working with MacBook Pros?
    Brother 7360: http://www.amazon.com/Brother-Printer-MFC7360N-Monochrome-Networking/dp/B004QM99 K0/ref=wl_it_dp_o_npd?ie=UTF8&coliid=I15YVL1HDHBT59&colid=RBYVZUYOZJW
    Brother 7065: http://www.amazon.com/Brother-Printer-DCP7065DN-Monochrome-Multi-Function/dp/B00 4ULP9QA/ref=wl_it_dp_o_npd?ie=UTF8&coliid=I145LC68RYCBED&colid=RBYVZUYOZJW
    Brother 7860: http://www.amazon.com/Brother-Printer-MFC7860DW-Wireless-Monochrome/dp/B004QM99J G/ref=wl_it_dp_o_npd?ie=UTF8&coliid=IK7O05NXDN5B&colid=RBYVZUYOZJW

  • Is VHDX for data drive considered good practice on a client PC?

    Hi!
    I don't like putting user's data files (documents, etc.) inside the user's Documents directory on C:. Instead I prefer having them on a D: disk, separate from the OS. On the other hand I don't want to create a fixed size partition as I consider it a waste
    of space, especially when everything is on a rather small SSD.
    Therefore, I consider creating a virtual hard disk (VHDX) on my C: drive and making it dynamically expanding. This would allow me to store data on that "separate" disk which is actually an expanding VHDX file on C:. One problem is that for some
    unknown reason Windows 8.1 is not able to auto-attach such disks on startup, but I have seen some workarounds to auto-mount them through tasks.
    My question is the following: Is it considered good practice to put all data files on such a dynamic VHDX instead on a separate partition? Reading the VHDX explanations it looks like this file format is very stable (even in case of power loss) and is widely
    used in virtual servers. Performance should be also very good. Therefore I don't see any reason to not use it for my data drive. Or are there any drawbacks?
    Thanks in advance for any help.
    Best regards,
    Anguel

    Hi,
    Since the VHDX is created on C which should be the system partition, I don’t think it is more safety than separate partition.
    Please consider that once the system corrupted and we have to format the C to reinstall the System, it may be difficult for us to recovery the date. But the separated partition will be easily stayed without changes.
    You can try to shrink the C volume in Disk management to create a new partition.
    Just my thought.  
    Kate Li
    TechNet Community Support

  • Faxing from Mountain Lion with a multi-function printer

    I recently upgraded to Mountain Lion from Lion. Of course, my Apple external modem hasn't worked since the initial upgrade.
    I hadn't done too much about this, but it really is awfully convenient to fax from my computer, vs. printing something out and putting it in the fax machine. (I have a stand-alone one.)
    I DO have a Canon multi-function printer (the MX870). When I set it up (which was a nigthmare) I didn't setup the fax portion because I HAVE a fax.
    But now ... well, I'm tired of not being able to fax from my computer. So I know I SHOULD be able to, but I haven't been able to get it to work. I connected the phone line (it's on a splitter with the other portion going to our comcast cable modem.) But it's not visible via the "add print or scanner" preference. The manual is less than clear.
    Do I need to add some Canon software? I'm not at home now, but I'm thinking I'll try that next.
    Any help wold be much appreciated. I know I could buy a new external modem, but as I'm about to purchase a new Retina MacBook pro, I'd just as soon not!
    (P.S. Perhaps this goes in networking.)

    Yes absolutely.  I set it up last Fall and have been using it until last week, at whick time I lost wireless connectivity with router for no reason at all.  I can not remember how to do it now and I am looking for the answer myself.
    This link to an online chat on www.hp.com with a tech might help you.
    http://h20180.www2.hp.com/apps/Nav?h_pagetype=s-006&h_lang=en&h_cc=us&h_product=3204781&h_client=S-A...
    I unfortunately upgraded my browser to IE8 last week and the chat support online does not support that browser.  If you get an answer, I would appreciate it if you would post the answer on this thread so that I can re-learn it myself.  Thanks.  Good Luck.

  • Workaround good/bad practice or does it not matter...??

    Hi,
    I have a project that requires other shared actions to hide./show something and was wanting a quick workaround for Hide 1 show 9 so I did as follows..(bear in mind I am using CP7 not 8)
    I copied my hide1 show 20 slide from another project, which retains the connection between buttons and images etc, but as this was too many for my other project, I just set things on the copied slide not to  displlay in output etc adn then renamed the ones I wan to refer to in the new project adn it all works great, however, if wer are doing this is this bad practice as any other CP editor further down the track, needs to edit the project, might think that this is a mess and mish mash with ttoo many objects (although hidden) on the slide and maybe make it more difficult for them.
    My initial thinking on that is while it may look a bit of a mess, My approach to any exising project is to deconstruct it to see exactly what is going on, but some otheres might just look at it as a real pain. (I did it this way as I could not edit a shared action in CP7)
    So, I was just wantig to pose this question to the community and get any feedback on your thoughts about this approach...? (I hope I have explained this correctly and is understandable etc)
    Cheers
    Rossco

    Hi Lilybiri,
    Sorry for the delay in responding.
    I would be interested in your workflow for editing shared actions.
    Hopefully this will be clearer for my explanation of how I initially thought of for editing my shared action...please let me know if this is still not clear.
    I had a Show 1 Hide 20 shared action, using smartshapes as buttons and aside from checkmarks (Ticks) and other images etc.
    I needed to create another similar advanced/shared action, but did not have the time to do so, I needed to just change the existing shared action.
    To do this, I copied the shared action to another project and tried to think of a way I can edit this just by changing the items on the slide. So I tested it out, by selecting a  number of images/buttons and making the ones I did not need, to not be buttons and to not show in output, then just renaming the ones I wanted to show etc...
    And it worked well, so I was happy with that outcome. It may have taken me a while to figure it out initially, but now I know it can be done :-)
    The only negative that some of my colleagues have said, are as follows,with my response back to them.
    Issue: The slide will be a mess as all those items/images are still on it. My response:You can hide the items not used so the slide will not look messy to another CP editor.
    Issue: the images etc will make the file too big and unwieldy My Response: remove the images not needed and the file size will not be a problem.
    Issue: File will be messy for another CP editor to change and take un-necessary time. My Response: Anyone who is a CP user, will/should know how to deconstruct and edit an existing file.
    I hope that makes it clearer :-)
    Cheers
    Rossco

Maybe you are looking for