301 redirect - best way?

i've been reading about 301 redirects which talk about modifying either .htaccess or httpd.conf but none of the suggestions i've found are working... my goal: if someone enters example.com, i want the server to change the url to www.example.com
i've read server admin does not do 301 permanent redirects. does anyone know the best way to do this? thanks.

Hi Scott,
I recommend not doing major edits to the config files in the /etc/apache2/sites directory. These are sometimes 'auto-cleaned' of custom edits by Server Admin when editing and committing through it (very annoying). Here's what I did that works well for me and has not been auto-cleaned so far:
1) Make a dir /etc/apache2/users
2) Make new files in that dir that have names based on your server's web users, e.g. myuser.conf (should not be system users, and not have their web directories in the /Library/Webserver area, IMHO).
3) Add *Include "/etc/apache2/users/myuser.conf"* to the end of and inside of the <VirtualHost> directive in your site config file in question from /etc/apache2/sites dir.
4) Add all your custom edits to the user file you need, in this case the 301 redirect (see below for my favorite add-www-301 redirect). If using BBEdit, make sure to re-lock the files when done, but you can leave them open.
5) In Terminal run +apachectl -t+ to make sure you have no syntax errors in your config edited files, or the Apache will crash when you try to restart it, taking your sites off-line.
5) Open /var/log/apache2/error_log, with +tail -F -n 50 /var/log/apache2/error_log+ or in Console on the server.
5) Then, in Server Admin under Web -> Sites, make a trivial change and reverse it (like checking then un-checking a box) as this allows you to gracefully restart Apache without screwing up the Webcache feature (see Web PDF docs about not using +apachectl graceful+ ).
6) Go back to your Apache error log and make sure Apache did not crash. If it did, reverse your edits and restart Apache again.
Here is my favorite add-www-301 redirect:
<IfModule mod_rewrite.c>
RewriteEngine On
# Google canonical redirect
RewriteCond %{HTTP_HOST} ^\[^\.\]+\.....?$ \[NC\]
RewriteCond %{HTTPS} !^on$ \[NC\]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 \[R=301,L\]
RewriteCond %{HTTP_HOST} ^\\[^\.\\]+\.....?$ \[NC\]
RewriteCond %{HTTPS} ^on$ \[NC\]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 \[R=301,L\]
</IfModule>
As opposed to other redirects that state the name of the domain, this will cover sites that have multiple domains assigned to them and up to four letters in the TLD (like .info). Also, it handles https redirects as well. Always adding (or removing) the www is important to keep your sites page ranking in Google from being diluted by the non www use (or use) of the base domain. You may already know this, of course.
The new book http://buildingfindablewebsites.com/ explains this well, though its mod_rewrite solution in limited. Caveat: HTTPS part may not work well with older browsers that do not support HTTP 1.1.
Larry

Similar Messages

  • 301 Redirections - Proper way to set up?

    Hi - I have an quick and hopefully easy 301 redirect question.
    Here is the duplicate title Notice from Webmaster Tools (and this is also showing duplicate content in SEOMoz).
    So obviously I need to do a 301 redirect.
    The top level menus on the site point to the /about version and not the index.html
    the /index.html is NOT the one I want to use for the 301 if possible - does anyone have a suggestion for how to accomplish this?
    Thanks!

    Have you just tried doing the basic issue there and changed title tags?
    Had someone ask this on the forums before and over complicating looking at 301's when they just changed names of items and page titles and fixed it
    Not sure what you mean about /about etc.
    If you have an about page you got several pages related to it? You have a dropdown menu? So you made a folder /about and the landing page index.html?
    If not and it is just one page and you did that you do not need to. /about as a page is all you need.
    You got to remeber that when  you post on the forums you see all your information and sites, we do not so you need to be detailed or exact in your posts so we can get to the same pooint as you in our heads

  • Is this the best way to redirect using servlet?

    I making a servlet application where the user sends some FORM value to a servlet. I want the servlet to redirect to the answer page after processing the page. Do you think the following code is the correct way of doing?
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            String dnaText = request.getParameter("dnaText");
            /*Getting the tranlated output from dnaToRna method*/
            String finalVal = null;
            String link="http://www.mail.yahoo.com";
            try{
                 finalVal = String.valueOf(dnaToRna(dnaText));
                 response.sendRedirect(link);
                }catch(Exception ex){}
        }

    Many thanks for replying.
    My output file have lots of html code and I dont want to make my servlet heavy with unnecessary code. So I have decided to use another page result.jsp as output file. In result.jsp I intend to call these objects which is storing the value here to display the result.
    As I am new to jsp. I am still in the processing of thinking the best way to handle errors. I have created a method which takes in int values and returns corresponding String values. Like this
    public class DnaToRna extends HttpServlet {
       String error=" * NULL *";
    private String printError(int i) {
            if(i==1){
                error = "There is an error in String to char array";
            }else if (i==2){
                error = "There is an error in your DNA sequence";
            return error;
        }Since error is declared as a class object, if there is no error then I think it should rerun the String NULL. Which can be used to tell people if there is no error. On the contrary if there is really an error, I can use this to tell what is exactly causing the error.
    Although I am new to web programing. I think this would be nice.
    Here is the other method
    public String dnaToRna (String dnaText) throws Exception{
                /*Trim()*/
                dnaText = dnaText.trim();
                /*Codes for Dna to Rna translation*/
                if(Pattern.matches(".*[^atgc]+.*",dnaText))
                return printError(2);
                return dnaText.replaceAll("t","u");
                }

  • Content managed 301 redirects

    I am trying to work out the best way to allow content authors to create and manage 301 redirects within the CMS. We are using GSF for friendly URLs, but they also want to be able to (for example) create a catchy URL to be distributed on print media that will redirect to an existing page within the site (or potentially to a page on an external site).
    I know that I cannot change the response headers in the JSP, and so am looking at the best way to do so within the existing software stack. The GSTAlias class appears to be almost what I need, but only supports 302 redirects, not 301.
    My current though is that I will implement a custom filter (which will compare the incoming URL against the list of redirects that it retrieves from WCS and send a 301 if needed) and insert it into the filter chain, but I was hoping to get some feedback on this and see if anyone had done this before or knew of a better way to do it.
    Cheers,
    Stephen

    Previously I've done redirects exactly like you, using a custom filter which was installed on the Satellite servers.
    My implementation ended being a bit more complicated since all code using friendly URLs had to be executed within a cached code block due to an earlier design decision. What I ended up with was a setup where the templates could generate some output that could be interpretted by the filter. Like #R#301#http://somepage.com# which the filter picked up. Unfortantely that approach required me to read through the output of the pages and add some caching to often requested URLs in order avoid parsing through the content again.
    If you have GSF on your site as well, you might have a look at com.fatwire.gst.foundation.httpstatus.HttpResponseStatusFilter which enables you to communicate status codes from the ContentServer. Note that proper redirects are not supported, or at least not implemented.
    Also this requires your code to make the decision in a XML based wrapper, since you cannot communicate response codes from JSP.
    If the requirements are quite simple, you can create a basic asset type containing the URL to match and where to redirect to and in your XML wrapper do a very simple sql lookup which should give you enough performance in order to have this executed in an un cached element. The SQL cache will save you for the common requested URLs.
    Please note, that if you are running remote satellite servers I am not quite sure how this will work, if they support handling other response codes and if they can handle additional information found in a 301 redirect.

  • 301 redirect question

    I have a website with a couple thousand pageloads a week and
    a google rank of 5.
    I have set up a blog on the same server in a directory and
    now want to move the blog to the domain name and have the traffic
    and the rank go to the blog rather than the website.
    Some say do 301 redirect.
    Some say just move your blog index.php.
    Some say erase the WWW.domain redirect, leave THAT as the
    website and use the NO-WWW.domain for the blog?
    Any advice on this please?
    RJ

    Thanx Sonjay!
    The website is not going under, it is important, but the blog
    is more important regards bringing in search results. I want the
    arrival to the blog and then go to the website if they want.
    I tested the 301 htaccess and it worked fine, page rank
    carried over and worked instantly. But I had not figured that about
    1000 links and graphic pointers are now wrong! :) Not quite sure
    what to do about that.
    I have most everything for the website in the root and quite
    a bit of the blog there too, I suppose I could move most everything
    in the root to domain/blog/?
    rackjite.com is my domain, and serendipity is the director
    the blog is in.
    So I though I would try the PHP redirect in the index.htm
    file.
    <?php
    header( 'Location: http:/rackjite.com/serendipity/' ) ;
    ?>
    I tried that with the index.php and no slash and so forth
    with no luck. I put it at tippity top as required and it doesnt do
    anything at all. I do not know if this is a good way of doing it
    but I did want to see what actually happened. If the page rank went
    with it?
    I also wonder about putting the blog index.php into the root
    and what would happen. Does it still default to index.htm? if there
    is a index.php.
    My firend with the WWW suggestion has always been a bit weird
    about WWW. He is a WWW advocate of sorts and I dont really know
    what the point is, but it is colored by his prejudice for using
    WWW.
    Im confused on how best to do this.
    One other thing to ponder, the webpage has a grank of 5 and
    the blog even now has google rank of 4, how important is that
    difference?
    I have quite a few links out there to the domain, perhpas I
    could just ask for new links under the blog name and hope they will
    add that too? Been around long enough to know that wont work very
    well though... :)
    thanx again
    RJ

  • 301 Redirect

    I have a few years of Dreamweaver design experience and am
    fairly well versed in html, css, etc. However, I have never had to
    create a 301 redirect. I have purchased a .com and .org for a
    non-profit site I am building and therefore, would like anyone who
    types in the .com to be redirected to the .org. Any advice would be
    greatly appreciated.

    .oO(PeteC)
    >cabett wrote:
    >> I have a few years of Dreamweaver design experience
    and am fairly
    >> well versed in html, css, etc. However, I have never
    had to create a
    >> 301 redirect. I have purchased a .com and .org for a
    non-profit site
    >> I am building and therefore, would like anyone who
    types in the .com
    >> to be redirected to the .org. Any advice would be
    greatly appreciated.
    >
    >Best to do that with a DNS alias - talk to your host.
    No. That would lead to duplicate content. A 301 is the
    correct way to
    handle such things. On Apaches all it needs is a simple
    directive in a
    .htaccess file on the .com site (assuming that both sites are
    hosted on
    different servers or at least on different vhosts):
    RedirectPermanent /
    http://example.org/
    If both domains resolve to the same server and the same
    directory, then
    it might require mod_rewrite to make sure that the redirect
    is only
    triggered when the .com is requested.
    Micha

  • Advice re.  301 redirect / htmaccess file

    I hope this is the correct place to post this question, re. http://www.cumbria-dog-training.com/index.htm
    I originally had an intro page -  index.htm with an entry page Home.htm.
    Late Oct / early Nov I removed the intro page and renamed Home.htm to index.htm.
    However, searches for cumbria-dog-training.com give a result the original Home page - unless I put the index.htm. in the search.
    I’ve been advised to create a 301 redirect.
    My webhost, Crystaltech, said that I need to do that, having made it I then upload an .htaccess file.
    My website design knowledge is limited to say the least. Is there anything I need to be wary of or avoid doing.
    Many thanks for any advice.
    Paul

    Unfortuantely that's not my problem.
    If you type    cumbria dog training  into google, you will find the site positioned at around number 42.
    However, this is  www.cumbria-dog-training.com/HOME.htm    This is the OLD page that I want to get rid of and replace with
    http://uk.search.yahoo.com/search;_ylt=AsfH_jph7OMXw_iz68Gr1Hs4hJp4?vc=&p=cumbria+dog+trai ning&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-702
    (Position No. 7)
    I just don't know the best way of doingt it for Google.
    I hope this makes sense!
    Paul

  • 301 redirects using .htaccess

    Hey Guys, I've got to redirect a couple of pages on a site for SEO and am not sure the best format to code it in. I've looked up a bunch of so-called tutorials and they all say what a 301 redirect does but nothing as far as how to code it....
    For example, the courses page on the site is not there anymore cause they are now selling through a third party sooooo
    www.bliqm.com/courses.html   ->   needs to redirect to   ->  www.bliqm.com/lss_blended.html
    How would I got about doing that???
    Thanks in advance!
    by the way the site is http://www.bliqm.com if needed.

    Here's a page that tell you how to add the .htaccess file.
    http://iweb.dailynews.webege.com/PHPparseerror.html
    On the image below you see what lines to add. Lines 6-8 are the ones you need :
    !http://iweb.dailynews.webege.com/Howto_publish_to_a_subdomain_with_iWeb_files/Smultronhtaccess.png!
    More info here :
    http://httpd.apache.org/docs/1.3/howto/htaccess.html

  • Best way to migrate iTunes and iPod to new hard drive

    Currently, my iTunes Library is referencing music files that sit on my music data drive (E:drive). My Library is actually on another data drive (D: drive), while my OS and apps are on the C: drive. I also have a networked Network Attached Storage (NAS) drive that has a duplicate copy of all of my music files.
    One of the reasons I have the NAS is to have 24/7 access to my music files through a Sonos Zone Player system (highly recommend this) hooked up to my stereo. The Sonos player is able to pickup all of my playlists but because iTunes creates the plalists thinking that all of the songs reside on my E:drive, they are broken links as far as Sonos is concerned.
    So my quesion is, what is the best way to redirect my iTunes Library so that it pulls the songs from the NAS rather than my internal E:drive? Since the NAS is always on, I don't care that when I want to play songs on my computer, it pulls them off of the NAS. In "migrating" the music file links, I'd like to maintain all of my rankings, play counts, and playlists. Is this possible?
    If not, then at a minimum, I'll be swapping out my E:drive for a larger one and need to know the best way to migrate the music files. It would be simple to just take out my current music file drive, swap in the new drive, and copy the files from the NAS drive onto the new drive. Do I need to de-authorize my computer at the start so iTunes doesn't think I'm giving permission to a new computer? Will my play counts, ratings, and playlists still show up? Regarding the latter, I'm guessing yes since the Music Library isn't being touched (on the D: drive).
    Hope this makes sense to someone.
    Thanks in advance,
    Steve
      Windows XP Pro  

    Well, you'll need to reinstall iTunes and the iPod updater.
    Did you happen to save the iTunes library file?
    What are the iTunes library files?

  • What is the best way to add "meta tags" in edge?

    Trying to add meta tags for search engines, what are the best ways to do this?

    With the latest version of Edge (3.0) is still the best practice to edit index.html or is there a better one?
    Y try for example...
    var meta1 = '<meta name="robots" content="index, follow" />';
    $(meta1).appendTo("head");
    ...in creationComplete or in document.compositionReady but I can't see these lines in index.html file, are stored in index_edgeActions.js file.
    But maybe that works to attach the meta tags with append to head because it does work fine (and neither are saved in the index.html):
    var favicon = "<link rel='shortcut icon' href='images/volicon.png' type='image/png'/>" ;
    $(favicon).appendTo("head");
    I don't know if Google detect meta tags stored in index_edgeAtions.js or is more recommended to modify index.html manually with notepad.
    Maybe the best practice are save and publish Edge project with a name different than index (for example project.an and project.html) and to create an index.html manually with meta tags, code of Google Analytics and Google Tag Manager, etc., and with HTML meta http-equiv Attribute for to redirect immediately to project.html generate with Edge (remember disallow project.html in robots.txt). In this way is not necessary to modify the index.html file each time that we publish.
    How do you see?

  • What is the best way to send auto mail with excel(generated by query) attachment?

    Hello,
    Need to generate first data from stored procedure and the save it to an excel file and then send mail with the same excel file.
    So am searching for the best way so that i could do all process in a single task with daily or monthly schedule.
    As per my understanding, we could it via SSIS and by sql server using
    sp_send_dbmail.
    But i have to generate excel file first by stored procedure and then end it by mail.
    So please suggest the best way to accomplish all task in a single task.
    Thanks
    Ajay 

    Hi Ajay,
    As shown in the blog mentioned by Syed, to delete records from the Excel file, you need to use Update OpenRowset command to update the corresponding rows to blank.
    Alternatively, you can also use Derived Column Transformation or Conditional Split Transformation after the OLE DB Source so that you can replace the target rows with NULL before exporting to Excel destination or just redirect the expected records to the
    Excel destination.
    Then, in the Control Flow, you can add a Send Mail Task to send the Excel file by setting it as the attachment. The following screenshot is for your reference:
    Regards,
    Mike Yin
    TechNet Community Support

  • Best way to implement app wide process

    I am working on an application that has a list of art work in an sql report.. I want to be able to add each piece to a collection of items (which is stored in a table), so I added another column to the sql report to store the id of the art work. I am just wondering what is the best way to implement the process to insert the item to the collection of items. Since I want to do this from multiple pages - link from art work sql report; link from the edit page for a particular art work; and on the artists page where there is also an sql report, I thought it may be best to have an application process, to save duplicating the process on multiple pages.. however I don't think there's a way to pass the id of the item to the application process? as I was thinking best to have the application process conditional based on request, and then have the link as a doSubmit().
    So is it best just to have the link redirect to the same page, passing the id of the item, and then having a process that runs before header that inserts the item, then assigning the item to NULL?
    Thanks in advance,
    Trent

    Daniel:
    Thanks for the info. I have found that the IFRAME works nicely for some applications,
    however, some applications I want to re-write the front end to look better in
    the portal rather than screen scrape.
    Thanks for the help
    Ryan
    "Daniel Selman" <[email protected]> wrote:
    Ryan,
    Check out the thread (a few days old) titled "Different ways of creating
    portlets".
    Sincerely,
    Daniel Selman
    "Ryan Richards" <[email protected]> wrote in message
    news:3d2eda12$[email protected]..
    I have a few existing applications that I need to port over to portletsin
    Weblogic
    Portal 4.0. One application is a servlet based web application witha few
    html front-end
    screens. I am trying to determine how to do this in the best way. Ihave
    noticed
    that portlets behave differently inside the portal than do stand-aloneweb
    apps.
    Any help would be appreciated.
    The other web application is the Microsoft Outlook Web Access. (Thisone
    is going
    to be difficult because it is actually an ASP app. I dont know if thisis
    possible
    without building some proxy code between bea and iis.)
    Thanks
    Ryan

  • Repost-Best way of using connection pooling

    I am reposting this, seems best suitable in this category.
    I am using Eclipse 3.1 along with Tomcat 5.0, MySQL 4.1, J2EE1.4. I could set up the JNDI Dataresource connection pooling and tested with small test servlet. Now thinking of having common methods for getting connection / closing / commiting ....etc.
    I wrote following. [Please let me know whether it is correct way of doing it - as i am not very sure]
    package common;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;
    import org.apache.log4j.Logger;
    public final class connectionManager {
         private static Logger logger = Logger.getLogger(common.connectionManager.class);
         public connectionManager() {}
         public static Connection getConn () throws NamingException, SQLException
    //JNDI DataSource connection pooling
              Connection conn = null;
              try{
                   Context initContext = new InitialContext();
                   Context envContext  = (Context)initContext.lookup("java:/comp/env");
                   DataSource ds = (DataSource)envContext.lookup("jdbc/TQ3DB");
                   conn = ds.getConnection();
              }catch (NamingException ne) {
                  new GlobalExceptionHandler(logger, ne);
                   conn = null;
                   throw new NamingException();
              }catch (SQLException e){
                   new GlobalExceptionHandler(logger, e);
                   conn = null;
                   throw new SQLException();
              return conn;
           }//getConnection
         public static void commit(Connection conn) throws SQLException
              conn.commit();
         public static void rollback(Connection conn) throws SQLException
              conn.rollback();
           public static void setAutoCommit(Connection conn, boolean autoCommit)
                                        throws SQLException
                conn.setAutoCommit(autoCommit );
         public static void closeConnection(Connection conn) throws SQLException{
              if (conn != null) {
                   conn.close();
                   conn = null;
         }//closeConnection
         public static void closeResources(ResultSet oRS, PreparedStatement pstmt) throws SQLException
              if (oRS != null) {
                   oRS.close();
                   oRS = null;
              if (pstmt != null) {
                        pstmt.close();
                        pstmt = null;
         } // closeResources
    }//ConnectionManager
    I am having a login form which submits user name and password. I am checking this against the database. Following is the servlet to do that.
    package login;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import common.*;
    public class loginServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {          
              doPost(request, response);
         }//doGet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException,IOException{
              String userId = request.getParameter("userId");
              String password = request.getParameter("password");
              ** call a method to validate the password which will return the
              ** User Name for authorized users and null string for un-authorised.
              String uName = validateUser(userId, password);
              //if uName is null .. user is not authorized.
              if (uName == null){
                   //redirect to jsp page with error message
                  RequestDispatcher rd =
                       getServletContext().getRequestDispatcher("/jsps/mainmenu.jsp");
                  if (rd != null){
                       rd.forward(request,response);
              else{
                   // the user is valid - create a seesion for this user.
                   HttpSession userSession = request.getSession(true);
                   // put the user name session variable.
                   userSession.setAttribute("userName", uName);
                   //redirect to Main menu page
                   RequestDispatcher rd =
                        getServletContext().getRequestDispatcher("/jsps/mainmenu.jsp");
                   if (rd != null){
                        rd.forward(request,response);
         }// end of doPost
         private String validateUser(String userId, String password)
                   throws SQLException{
              String returnVal = null;
              connectionManager cm = new connectionManager();
              Connection conn = null;
              PreparedStatement pstmt = null;
              ResultSet oRS = null;
              try{
                   //get the connection
                   conn = cm.getConn ();
                   //get records from user table for this user id and password
                   String sQry = "SELECT  user_login FROM user "
                             + "where user_login = ? AND user_pwd = ? ";
                   pstmt = conn.prepareStatement(sQry);
                   pstmt.setString(1, userId);
                   pstmt.setString(2, password);
                   oRS = pstmt.executeQuery();
                   //check for record
                   if (oRS.next()) {
                        returnVal = oRS.getString("user_login");
                   }else {returnVal = null;}
                 }catch (Exception e){            
                      returnVal = null;
              }finally{
                   cm.closeResources(oRS, pstmt);
                   cm.closeConnection(conn);
              return returnVal;
    }// end of servlet class
    But i am unable to compile it and i am also getting lots of warnings.
    I am getting error at line
    1)String uName = validateUser(userId, password);
    Unhandled exception type SQLException loginServlet.java TQ3/WEB-INF/src/login line
    Following warnings:
    2)For loginServlet Declaration
    The serializable class DBTest does not declare a static final serialVersionUID field of type long loginServlet.java
    3)The static method getConn() from the type connectionManager should be accessed in a static way
    4)The static method closeResources(ResultSet, PreparedStatement) from the type connectionManager should be accessed in a static way
    5)The static method closeConnection(Connection) from the type connectionManager should be accessed in a static way
    Definitely I am doing it wrong but exactly where? I am having very strong doubt the way i am using connections is not the correct way. Pls help me.
    regards
    Manisha

    I am in a search of best way to use connection pooling. Initially was using simple JDBC call, then modified to JNDI, afterwards tried to have common class. Later came accross the idea of Singleton/Static. I wanted to have a common class which will handle all connection related issues and at the same time give good performance.
    With due respect to all Java Gurus: i got all from web articles/tutorials/java forum etc. There is a long discussion regarding Singlet vs static in this forum. But finally got confused and could not figure out in my case which method shall i make use of, so tried both.
    What I want is somebody pointing out flwas inside my 2 code snippets and guide me about which method shall i adopt in future.
    Static way:
    package common;
    import java.sql.Connection;
    import javax.sql.DataSource;
    import java.sql.SQLException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public final class ConnectionManager_Static {
         private static InitialContext ctx = null;
         private static DataSource ds = null;
         public ConnectionManager_Static(){     }
         //as the staic method is updating static var i am synchonizing it
         private static synchronized void getDatasource () throws NamingException, SQLException
              if (ds == null){
                   ctx = new InitialContext();
                   ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MySql");
         //making getConnection() also static as it is not instance specific     
         public static Connection getConnection () throws NamingException, SQLException, Exception
              Connection conn = null;
              try{     
                   if (ds == null) {getDatasource ();}
                   if (ds != null) {
                        conn = ds.getConnection();                 
              }catch (Exception e){
                   throw new Exception("From ConnectionManager_Static",e);
              return conn;
           }//getConnection
    }Singleton:
    package common;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;
    public final class ConnectionManager_Singleton {
             private static ConnectionManager_Singleton INSTANCE = null;
              private DataSource datasource = null;
              // Private constructor for singleton pattern
             private ConnectionManager_Singleton() throws NamingException{
                   Context ctx = new InitialContext();
                   datasource = (DataSource)ctx.lookup("java:comp/env/jdbc/MySql");
             //synchronized creator for  multi-threading issues
             //another if check to avoid multiple instantiation
             private synchronized static void createInstance() throws NamingException{
                 if (INSTANCE == null) {
                     INSTANCE = new ConnectionManager_Singleton();
             public static ConnectionManager_Singleton getInstance() throws NamingException {
                 if (INSTANCE == null) createInstance();
                 return INSTANCE;
              public Connection getConnection() throws Exception
                   Connection con = null;
                   try{
                        con = datasource.getConnection();
                   }catch(Exception e){
                        throw new Exception("From connection manager singleton ", e);
                   return con;
    }Sorry, It's becoming long.
    Thanaks in advance,
    Manisha

  • Best way to handle calling the EP logon page

    I would like to be able to handle the following:
    1. Start EP in anonymous/guest mode (basically unauthenticated).
    2. Present an iview that allows a user to fill in some information but when he/she clicks on a button it would first check if the user is logged on and if not -- call up the EP logon page/self registrtion page.  After logging in/self-registrating, the iview would continue processing.
    What is the best way to handle this?
    Regards,
    Mel Calucin
    Bentley Systems, Inc.

    Hi,
    You have to download the com.sap.portal.logon standar "par" and modify the jsp file to simplify the logon page (maybe only input fields for user and password).
    then upload the new .par file to the portal and update the authschems.xml file to redirect the default method to the new ".par".
    You can insert an "enter" button in the home page that launh a pop up to a dummy page with property "default" authentication scheme. Automatically the Portal shows you in the little pop up the simplyfied login page to insert login data. The dummy page need to redirect the parent page to the portallauncher component and close itself.

  • Theory - Best way to store this type of data for retrieval?

    Hi everyone,
    So I'm pretty new to databases and I'm trying to figure out an efficient way to retrieve this kind of data:
    an ID that is 36 digits long
    col1 = {option1, option2, option3...}
    col2 = {option1, option2, option3...}
    coln = {option1, option2, option3...}
    I need to be able to perform queries on the data based on some concatenation of 3 digit sequences for the ID
    for example, I may want to retrieve all the records where the ID begins with '123' or where the ID begins with '123123', or '123123200', etc,
    There are going to be close to a billion if not more of these records
    the 3 digit sequences will always be a number between 000-255
    It is not necessary for me to have a 36 digit long ID, I simply chose that because it seemed like the simplest way to associate a record with its combination of 3 digit sequences.
    Like I said, I'm very new to databases. I've been doing a lot of reading on indexing and clustering and nested tables and partitions, but I'm not quite sure which of these I should pursue with this kind of data. Most of the examples that I've read about don't really deal about querying with variable precision.
    Would the best way to get this data simply be to use an 'is like' statement on the ID? If so, are there any kinds of indexing I should take a look at that would benefit from knowing that the is like statements would follow the format of <3 digits,3 digits,3 digits>? Also, at the data level, would it be more efficient to use hexadecimal to store the sequences of 3 digits since they conviently fall in the range of 00-FF? I'm just throwing ideas out there, I haven't found much help browsing the web, but maybe I haven't looked in the right place. If anyone has any ideas or places to redirect me, it would be great!
    Also, I know sometimes it helps to know the main kind of queries on the data that someone is primarily concerned about. In this case, most queries will be selective counts, for example finding the number of records whose ID's begin with '123006011' and col1='option1'.
    Thanks,
    Alex
    Edited by: user9022475 on Jun 23, 2010 9:37 AM

    So I'm starting to rewrite my code. I was shocked at how easy it was to implement the SAX parser, but it works great. Now I'm on to doing away with my nasty string arrays.
    Of course, the basic layout of the XML is like this:
    <result1>
    <element1>value</element1>
    <element2>value</element2>
    </result1>
    <result2>
    I thought about storing each element/value in a HashMap for each result. This works great for a single result. But what if I have 1000 results? Do I store 1000 HashMaps in an ArrayList (if that's even possible)? Is there a way to define an array of HashMaps?

Maybe you are looking for

  • Contextual Share to Facebook Album - Limited Albums Listed

    Using 10.8.2, I am attempting to share several photos to existing albums in Facebook. When I select the photos and pick the Share to Facebook via option-click, I only see a few of my Facebook albums. Why are only a few (not all) listed? How can I mak

  • Some discussions here cause me to fear upgrading to Mavericks.

    I have two Macs (iMac 24 inch early 2009 with 8 GB using Lion and MB Pro 16 inch with Retina using Mountain Lion). I use a Western Digital I TB My Passport for Mac on my MB pro and a Time Capsule for backup on my iMac. Some discussions here mention p

  • Help with putting a logo on top of a photo as a web page heading

    I am new to this and stuck with what i imagine is a simple problem. I need to replace a former name with a new one on a website. The old logo has also been changed. The page headings have been changed also. I have a logo scanned as a jpg but can re-s

  • Partner Link on left side -- A bug?

    Hello,  I am using 11.1.1.7 I have a problem where inside the BPEL designer sometimes the partner link is on the left side while in the composite screen it is on the right.  It seems to be re-producible -- if you have a file adapter configured in the

  • Flash Drives and Network Homes

    I have a problem that is driving me nuts. If a kid logs into an OpenDirectory-based network home on an older iMac (white, 2007) and plugs in a flash drive, the drive mounts no problem to their desktop. If the same kid logs into the same account on a