Saving preferences with JSP

I have an application for which I'd like to develop a web interface. I've never really worked with servlets, but know Java and PHP fairly well. In PHP, I'd create a page which would save the user's input to a file, then use this data to connect to a database. On the desktop application I've developed, the data is saved using java preferences. I'm unsure how to save this data for use with a JSP. The user would need to enter a password (which would ideally have to be set from the desktop application), and could then use the JSP page to access the database. Is there any way I could save such a file using a JSP page, then load the settings from it?

Download the classs files for servlet from:
http://java.sun.com/products/servlet/download.html
To run/test your servlets/JSP You should also download a servlet/jsp capable web server e.g. Tomcat:
http://jakarta.apache.org/tomcat/index.html
Find some good tutorials here:
http://java.sun.com/developer/onlineTraining/index.html

Similar Messages

  • Lion not saving preferences

    I just switched to a new retina macbook, with os 10.7. I'm having trouble with Linotype Font Explorer X not retaining its settings - previously, you could turn a font on & it would stay on. Although sometimes it does retain some of the font settings, but not all.
    I've also noticed other programs occasionally not saving preferences.
    Is this a known issue with Lion?

    Make sure the systemprefs plist file is not locked. If it is, unlock it. If it isn't, delete it then restart.
    To find the file
    1. Make Finder active. Choose 'Go' from the menu bar, hold down the option key.
    2. Choose Library (you must have the 'option' key held down).
    3. Go to Preferences > com.apple.systemprefereces.plist
    4. Right-click (or hit 'cmd-i' on the keyboard) and choose 'Get Info'. If the 'Locked' option is ticked, untick it. Then Restart. If the 'Locked' option is not ticked, close the dialogue, remove the file to trash. Restart.
    5. What happens now is that system will restart at default system prefs. However, it should now save your new settings. To test it, just set one of the setting that you know didn't 'stick before', then restart and see if all is good. 

  • Help a new guys with JSP!

    Hi,
    i'm a new programer with JSP.
    I've created a class files that connect a database.
    But i would like to know how to write text with JSP?
    I would like to write a 'thank you' message after saving a form in a database.
    does its possible to have it in my class files?
    thanks for your help.

    Im not an expert on jsp or java but i will try to give my ideas.. i hope i can help you =)
    /* you could actually forward your servlet to your confirmation file like this : */
              ServletContext sc = getServletContext();
    .// just fill up here the variable msg , u cud write to its value your thank you message or something else like error messages
              RequestDispatcher rd = sc.getRequestDispatcher("/Confirmation.jsp?msg="+msg);          
              rd.forward(req, res);     
    /******* or u cud also throw ur request to the same jsp and display the ***/
    /******* message thru a form tag using javascript like this : ***/
    suppose your main jsp is this:
    <html>
    <head>
    <STYLE TYPE="text/css">
         .noBorder{
              border: white 0px solid;
              background-color: white;
              font-family:Arial;
              font-size:13px;
              font-weight: bold;
              color:green;
              width:300px;
              text-align:center;
    </STYLE>
    </head>
    <%!
    Connection conn;
    PreparedStatement pstmt;
    private doInsert(String name){
    // this is an oracle connection
    String sql = "INSERT INTO TABLENAME(FIELD1) VALUES(?)"
    try{     
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // just fill up the dburl , dnusername and dbpassword
    conn = DriverManager.getConnection(dburl,dbusername,dbpassword);
    pstmt = conn.prepareStatement(sql);
    pstmt.clearParameters(); // clear any previous parameter values
    pstmt.setString(1,name);
    pstmt.close();
    }catch(SQLException se){     
    }catch(Exception e){          
    }finally{
    if(conn!=null){
         try{
         conn.close();
         }catch(SQLException se){}
    %>
    <body>
    <form method=post"" name="msgscr">
    <tr><td colspan="2"><input type="text" name="msg" value="" class="noBorder" disabled/></td></tr>
    </form>
    <%
    if(request.getParamater("submit")!=null){
    // you could also add a return value for doInsert method to check whether the dbase insertion
    // is successful or not if the return value is true then the value for the document.msgscr.msg.value
    // is thank you otherwise u cud put "Unable to process your request" or other message
    doInsert(request.getParameter("name"));
    out.println("<script>document.msgscr.msg.value='Thanks you!!!!';</script>")
    %>
    <!-- this means that the request qill be thrown on this file-->
    <form method="post">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>
    </body>
    </html>     
    /**** or you could also do the confirmation message just by adding an **/
    /**** alert message using javascript like this: **/
    <head>
    <script language="javascript">
    function ValidateCreate(theform){
         if(theform.name.value==""){
         alert("name is required");
         return false;
         }else{
         alert("Thank you!!!!");
    return true;
    </script>
    </head>
    <body>
    <form method="post" onsubmit="return ValidateCreate(this)">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>

  • Mail - Error saving Preferences Msg

    I am unable to reset my junk mail filter. In Mail preferences I select RESET and this message pops up:
    Error Saving Preferences
    Writing your preferences to disk has failed. Your preferences may not have been saved. The permissions on -/Library/preferences may be wrong or your disk may be full.
    After getting this message, I used disk utility to repair permissions ( I did it twice and it appears that the same permission repairs occur each time I use repair permissions) I also tried to repair disk permissions usind Disk Warrior - with similar results.)  In addition, the disk is far from being full.
    Can anyone shed some
    TIA

    Amount of free space on my computer:
    Capacity: 499.76GB
    Available 432.54GB
    You are doing great on free space.
    I tried to "repair disk partitions" but this didnt work, and everywhere I looked on the web it would say that this does not work.
    It does work, but not for permissions issues on individual user files. It only has benefit on systemwide issues.
    I also did a complete TimeMachine restore. This didnt work.
    This is really only affective if you restore from a point in time when the issue did not occur which can be tough to know unless you try adding new Mail accounts every day.
    _Go to Your User > Library > Preferences.
    _Click on the Preferences folder once to highlight it.
    _Go to File > Get Info
    _Make sure that your user name is listed in the Sharing & Permissions window with Read & Write access
    _Go to the bottom of the info window and click on the pad lock to unlock it
    _Click on the cog / gear and then click on apply to enclosed items
    _Now try adding an account in Mail again.
    If the issue persists at this point it may be necessary to reset Mail which may require you to re-enter your account settings.
    Remove Your User > Preferences > com.apple.mail.plist to the desktop and then open Mail and try adding an account.
    Cheers.

  • Can i set different energy saving preferences for different accounts?

    Hi,
    I have bought an Mbox for my iMac. Its instructions for installation include disabling the energy saving features in Preferences.
    However, I also want to use the machine for many other purposes and would prefer to have energy saving activated.
    I set up a new account but it seems that energy saving preferences can't be different between different users on the machine? Is that true?
    I have tried unlocking and locking after making the change and switching between accounts (both admin accounts at present)
    imac   Mac OS X (10.4.7)   c2d, 2GB
    imac   Mac OS X (10.4.7)  

    Niel,
    When i entered the syntax exactly as you recommended, and as provided as example code within the general commands manual for PMSET ie
    do shell script pmset - a displaysleep 0 disksleep 0 sleep 0 password
    "password" with administrator privileges
    I got a syntax error "A identifier can't go after this identifier." and it highlighted [-a displaysleep]
    By inserting carriage returns to spread the command over lines, and adding brackets around the minutes, I got increasing acceptance of the script, up to the following point
    do shell script pmset - a
    displaysleep(0)
    disksleep(0)
    sleep(0)
    password
    "password" with administrator
    privileges
    at which point it said "The variable pmset is not defined."
    Can you suggest where I am getting stuck? Is something missing?
    Late news: A friend of mine found script on line which seemed to suggest that the following would be the format
    do shell script ("pmset displaysleep 0 disksleep 0 sleep 0") password "my password"
    with administrator privileges
    However, when i try to compile or run that it says:
    Expected “timeout” or “transaction” but found identifier
    and it highlights the word [administrator]
    If you can see where i am going wrong I'd love to hear from you.
    david

  • Error Saving Preferences on exiting Mail Preferences

    Hi, I am getting the Error Saving Preferences error on exiting Mail Preferences with advice to check disk space and directory permissions on ~/Library/Preferences. Not knowing what the official permissions should be I booted the iMac from the Leopard installation disk and in Disk Utility I repaired file permissions but this did not make any difference. I have followed other instructions I found in Apple Discussions which were for a previous OSX where I backed up the Mail directory and then moved ~/System/Preferences/com.apple.mail.plist to the Desktop. Per instructions I then fired up Mail which picked up my Mac account straight away but again on exiting Preferences without even adding any new mailboxes the same error cropped up... in fact I don't think a new plist was created. I returned the old plist and Mail directory.
    It may be worth mentioning that just before this problem cropped up I had been trouble-shooting another problem where every minute my active window would lose focus, I tracked this down to HP_scheduler (I have an HP all-in-one printer, C6180) and on killing the process the problem went away, but I think it was also a symptom of the real cause which is still unknown as the printer software has been installed for about a year, last update was months ago... but before I had tracked the issue down to this I had use MacScan2 to flush just my Safari caches and temporary files etc, it was running in authenticated mode, may mean something, may not. Subsequently to discovering HP Scheduler was to blame I uninstalled all the printer software using the HP uninstall package.
    Around this time a third problem transpired where settings were not being retained in various System Preferences. Unfortunately I didn't pick up on it straight away as being a third problem and now can't remember whether it started before the window lost focus problem or not. The first time it happened was when I tried to put MacScan2 into the startup list for my login, it could be added but on checking the addition it wasn't retained in the list and well I thought nothing more of it as it was the first time I had tried to do such a thing. Then I noticed the Mail issue just by chance and subsequently, through seeing someone else's problems logged back in 2006 I think, I noticed that although I could change screensaver I could not make a change in desktop photo stick.
    I have since reinstalled the printer software and I am no longer losing focus from the active window.
    However, I think it is probably the case that the Mail Preferences, Startup Items and Desktop Preferences issues are all the symptoms of one and the same problem and I would be very grateful if anyone is familiar with and/or knows of a solution to this issue.
    Many thanks for reading!

    Well, in the end I tried many things including lots of things that I thought wouldn't help such as cleaning out caches, running crons; I was using IceClean and pretty much tried every system maintenance option but to no avail. I have removed MacScan and have kept Norton, which this time found a few things in my .wine folder, but I have only performed a few full system scans as it takes a full day.
    This resulted in the knowledge that I would have to do a Leopard reinstall if that failed then a complete restore from TimeMachine which I knew would take ages, but fortunately the reinstall worked perfectly and effortlessly to solve the problem, and it only took 30 mins to update the security patches including 2 automatic restarts.
    Phew!

  • RichQuery Component - not saving criteria while Saving Preference

    I am using RichQuery component to advantage of saving preferences and picking them to execute it once saved. Using the out-of-box component with no customization.
    Criteria values are not as part of saving preferences.
    Ex. Ran the page, then enter criteria like employee name and then hit search button. It displays the result. Now saving preference using save button. I am thinking employee name(what i entered) will be saving as part of perference. Does this save criteria values? Somehow not saving it. Can anyone help me fixing this problem.
    Thanks

    Yes, I am using ADF BC viewcriteria for creating query component. Please try the sample from the below link
    http://andrejusb-samples.blogspot.com/2008/11/jdevadf-sample-adf-query-component-and.html
    Run the main.jspx file -> enter some criteria -> search -> then save -> give a name -> select the criteria from the dropdown.
    Thanks

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • Create a new directory in server with JSP

    Hi,
    How can I create a directory in server with JSP.
    File dir = new File("a");
    dir.mkdir();
    does not work. what do I do?
    best regards,

    Hi
    Check the following things.
    1. What is the path where you are creating the directory.
    2. Do you permissions to create file in that directory.
    3. do a delete on that filename if that exists just to be sure. isdeleted = filedir.delete(). Check the boolean flag isdeleted too.
    Thanx and Regards
    Aruneesh

  • Running other server-side applications with JSP

    Hi,
    I'd like to know, if is possible run with JSP (Servlet, or JavaBean) other application, which support COM. I used something like this in JavaScript:
    application=new ActiveXObject("excel.application");
    and I had all possibilities of its API. I'd like to use excel as data source for user-friendly data input.
    Thanks for all suggestions

    Hi,
    I don't realy understand your question.
    If your javascript work using activeX, this code is executed on the client side (like the excel application and the excel file).
    You can, with a JSP, generate the html page that contain the script.
    Where is the problem ?

  • Displaying an Image in an Excel Spreadsheet with JSP - URGENT

    Hi Peoples
    I can transfer the table I am using in to excel with JSP by doing:
    <%@ page contentType ="application/vnd.ms-excel" %>
    this works fine, though I have an image that sits within the table that I want to be displayed as well.
    Can this be done?? If so how???
    Thanks

    Try to insert the image into sheet from it's URL not from it's local file path
    Best regards

  • A problem in RMI with JSP..pls help

    RMI with Java is working fine,but...
    1. I am facing a problem when i use RMI with JSP..its throwing an exception during "Naming.lookup"..here is my code snippet:
    // i have stored the ServerInf and other classes in a package and i have imported it in the jsp code....object ref is getting created but lookup is throwing an exception...thoguh RMI registry is working(started)
    <%
    try {
    ServerInf ref = (ServerInf)Naming.lookup("rmi://localhost:1098/Server_bind");
    catch (Exception ex) {
    ex.printStackTrace();
    %>
    Pls tel me the cause.
    2. If i try to use RMI with Servlet and JSP, then wen the JSP runs then, it simply calls the servlet file and displayes a lonk to it instead of executing the servlet class. pls help me with this too...below is the invoking statement:
    <form method=post action='http://localhost:8080/servlet/MyRMIservlet'>
    hello <input type=submit value=submit>

    And the exception and error message is.....

  • How can I create a Login-page with jsp???

    Hello,
    I have to create a page with JSP code on the Netweaver Developer Studio.
    But I do not know how I do it.
    Can anyone tell me what to write in the portalapp.xml?
    An example would be very helpful.
    Thank you
    Greetings

    As you can see in the example:
    The portalapp.xml file (deployment descriptor) provides configuration information for your application, and defines the components and services in your application. For each component and service, you specify the implementing Java class and configuration information.
    For more information on the format of the portalapp.xml, see Deployment Descriptor (portalapp.xml).
    <application>
        <application-config>
            <property name="SharingReference" value="com.sap.portal.navigation.service, com.sap.portal.navigation.api_mimeservice, com.sap.portal.navigation.helperservice"/>
            <property name="Vendor" value="MY_COMPANY"/>
            <property name="SecurityArea" value="PERMISSION"/>
        </application-config>
        <components>
            <component name="SimpleNavigationExample">
                <component-config>
                    <property name="ClassName" value="MY_CLASS"/>
                    <property name="SecurityZone" value="no_safety"/>
                </component-config>
                <component-profile/>
            </component>
        </components>
        <services/>
    </application>
    You can only update in this example, your class name and other details:
    <property name="Vendor" value="sap.com"/>
    <property name="SecurityArea" value="MyCompany"/>
    <property name="ClassName" value="LOGINCLASS"/>
    <property name="SecurityZone" value="no_safety"/>
    Modify this portalapp.xml file as follows:
           1.      NAVIGATION SERVICE, so you must add references to the following portal applications that define these services:
            com.sap.portal.navigation.service
            com.sap.portal.navigation.api_mimeservice
            com.sap.portal.navigation.helperservice
           2.      In the <application-config> section, create the following properties that help to define the security zone for all components and services in this application:
    ○     Vendor: String identifying the company or organization that provided the application, for example, sap.com.
    ○     SecurityArea: String identifying the security area for the application, for example, NetWeaver.portal.
           3.      In the <component-config> section for the mySiteMap component, create the property SecurityZone to define the specific security zone for the component.
    For Permission, check this document:
    http://help.sap.com/saphelp_nw04s/helpdata/en/44/489e2df5ee4e35e10000000a1553f6/frameset.htm

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • Excel with JSP

    Hi everyone
    I relly do need some help...
    I have an Oracle Database and I need to:
    1. View my results (of any request) in an excel spreadsheet using JSP (I think this part is the easiest...)
    2. And that is my real problem: Use an excel spreadsheet to insert values in the database with JSP...
    I hope I made it clear because even for me it's really tricky...
    Thanks a lot...
    Yassi

    There is a example in Marty Hal;l's book"Core Servlets and JSP pages".
    It is static, but the same idea would work coming from a database.
    <HTML>
    <HEAD>
    <TITLE>Comparing Apples and Oranges</TITLE>
    </HEAD>
    <BODY>
    <CENTER>
    <H2>Comparing Apples and Oranges</H2>
    <%
    String format = request.getParameter("format");
    if ((format != null) && (format.equals("excel"))) {
    response.setContentType("application/vnd.ms-excel");
    %>
    <TABLE BORDER=1>
    <TR><TH></TH><TH>Apples<TH>Oranges
    <TR><TH>First Quarter<TD>2307<TD>4706
    <TR><TH>Second Quarter<TD>2982<TD>5104
    <TR><TH>Third Quarter<TD>3011<TD>5220
    <TR><TH>Fourth Quarter<TD>3055<TD>5287
    </TABLE>
    </CENTER>
    </BODY>
    </HTML>

Maybe you are looking for

  • Standby db memory size

    Hello, it's a simple question: when I have a Data Guard standby instance, does it need to have the exact same size of PGA/SGA as the primary? Or can it be downscaled and if so, are there any limits (ofc depending on primary workload). What would be a

  • Dispatch queue: com.apple.main-thread

    Adobe InDesign CS6 crashing with Lion. Solutions/Fixes? is this a Apple or Adobe based problem?

  • Mozilla Firefox is crashing non-stop, no matter what.

    The Mozilla Crash Report appeared on my computer screen recently so I went about trying to figure out the problem. I tried to open Firefox again and it wouldn't. I opened in Safe Mode and it worked until I tried to navigate away from the start page.

  • Duplication of memory card - how?

    I want to backup and duplicate the whole contents of my E: drive to a new card in the most efficient and foolproof way. I have all the readers etc. to connect the phone to the reader via PC. , so can one of our experts please tell me 1. Which card go

  • Handling File(s)

    Hello, I was wondering what would be the best solution when handling one or more files to be used within an application. I am talking about whether I should only keep their path in memory, and access them only when needed, or else I should load the c