Using " in JSp

In JSP, I want to have the following:
rs = st.executeQuery("select * from contacts where v='a' ");
But 'contacts' is actually stored in a String 'c', which makes it:
rs = st.executeQuery("select * from " + c + " where v='a' ");
which is wrong...
I know the correct one is:
rs = st.executeQuery("select * from \"" + c + "\" where v='a' ");
But can anybody explain how the \" works?

First you should move all of your jdbc code to a class, with that said:
this:
String c = "test";
"select * from " + c + " where v='a' ";will produce:
select * from test where v='a'
this:
String c = "test";
select * from \"" + c + "\" where v='a' ";
{code}
will produce:
select * from "test" where v='a'
{code}
{code}
is an escape character, telling Java to treat the character that follows it as a literal String                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Using a .JSP file for the webservice

    Hello,
    I am using a .JSP file to view my webservice, just like in this tutorial: http://otn.oracle.com/tech/webservices/htdocs/series/news/content.html
    But when I try to run my JSP file i get this error:
    500 Internal Server Error
    OracleJSP:
    JSP Error:
    Request URI:/InternAdressen-InternAdresProj-context-root/internadres.jsp
    Exception:
    java.lang.NoClassDefFoundError: _InternAdres
         java.lang.Class java.lang.ClassLoader.defineClass0(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              native code
         java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              ClassLoader.java:493
    and a lot more of errors like this. Can you help me?

    It didn't work. I still get this error:
    500 Internal Server Error
    OracleJSP:
    JSP Error:
    Request URI:/InternAdressen-InternAdresProj-context-root/internadres.jsp
    Exception:
    java.lang.NoClassDefFoundError: _InternAdres
         java.lang.Class java.lang.ClassLoader.defineClass0(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              native code
         java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              ClassLoader.java:493
         java.lang.Class java.security.SecureClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.CodeSource)
              SecureClassLoader.java:111
         java.lang.Class oracle.jsp.app.JspClassLoader.loadClass(java.lang.String, boolean)
              JspClassLoader.java:682
         java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String)
              ClassLoader.java:255
         oracle.jsp.runtimev2.JspPageInstFacade oracle.jsp.runtimev2.JspPageInfo.getInstFacade(oracle.jsp.provider.JspClassProvider, javax.servlet.http.HttpServletRequest)
              JspPageInfo.java:160
         oracle.jsp.runtimev2.JspPageInstFacade oracle.jsp.runtimev2.JspPageTable.getInstFacade(javax.servlet.htt[i]Long postings are being truncated to ~1 kB at this time.

  • Use of jsp-file in web.xml

    hello
    can anybody explain about , when we need <jsp-file> in web.xml
    and why we use this tag in place of <url-pattern>?

    If you want to declare a JSP in your web.xml file you use the jsp-file tag instead of the servlet-class tag. Normally there is no need to declare a JSP in the web.xml file unless you want to use init-params.
    Usually people can access a JSP directly wether it is declared in the web.xml or not. So it is not that the jsp-file tag replaces the url-pattern tag so much as the url-pattern tag is not needed for a JSP. However notthing prevents you from declaring the JSP in the web.xml and then mapping the JSP to a different url that doesn't end in '.jsp'.

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • Sigsegv - using a JSP/BC4J deployed application

    OC4J: developer's preview & JDev9iRC packaged version
    Info: accessing a .../xyz.jsp doesn't return,
    generates a SIGSEGV(11).
    Question urgent!!!!
    I'VE SEEN A (RECENT) POST ON THIS BOARD SPECIFICALLY DEALING WITH SIGSEGV ERROR. THE ELEPHANTWALKER MENTIONED THIS IS EITHER HARDWARE OR JVM/OS RELATED.
    WHERE DO I START LOOKING FOR A SOLUTION?
    ( - increasing stack/heap sizes
    , - move to different JVM (JDK1.3.0 ?)
    , - any known issues on AIX4.3.3 and JDK1.2.2?
    Previously I had no problems deploying and using (simple) JSPs and/or servlets in these environments. The problems seems to be related to JSP(UIX)/BC4J.
    Output to console:
    ==================
    SIGSEGV 11 (*) segmentation violation
    si_signo [11]: SIGSEGV: (*) segmentation violation
    si_errno [0]: Error 0
    si_code [50]: Error 0 [addr: 0xB997221F]
    stackpointer=311e0618
    Writing java dump to javacore62868.1014217828.txt... OK
    SIGABRT 6 (*) abort process
    stackpointer=311e0038
    Information in javacore62868.1014217828.txt:
    ============================================
    SIGSEGV received at 0 in . Processing terminated.
    Current Thread Details
    "ApplicationServerThread" (TID:0x800328f0, sys_thread_t:0x30ee16d0, state:R, native ID:0xa14) prio=5: pending=java.lang.ClassNot
    FoundException
    at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java(Compiled Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at oracle.jsp.app.JspClassLoader.loadClass(JspClassLoader.java(Compiled Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at oracle.jsp.runtimev2.JspPageInfo.getInstFacade(JspPageInfo.java:162)
    at oracle.jsp.runtimev2.JspPageInfo.compileAndLoad(JspPageInfo.java:369)
    at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:357)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:145)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:356)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:306)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java(Compiled Code))
    at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:108)
    at com.evermind.server.http.GetParametersRequestDispatcher.include(GetParametersRequestDispatcher.java:92)
    at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:284)
    at oracle.jbo.html.jsp.datatags.ComponentTag.doStartTag(ComponentTag.java:75)
    at UixBrowseEdit1.jspService(UixBrowseEdit1.jsp:50)
    at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
    at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:384)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:145)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:356)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:306)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java(Compiled Code))
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java(Compiled Code))
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java(Compiled Code))
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java(Compiled Code))
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java(Compiled Code))
    ----- Native Stack -----
    unavailable - iar 0 not in text area
    J2RE 1.2.2 IBM build ca122-19991217

    Jan -- The developer's preview requires the 1.3.1 JVM. Please see the installation instructions at
    http://otn.oracle.com/tech/java/oc4j/htdocs/oc4j-oow-install.html
    I'm not sure if the developer's preview was tested on AIX or not. It was tested on Solaris and NT. Also, I run it on Linux
    with a 1.3.1 JVM without any significant problems.
    Please try the 1.3.1 JVM and see if that solves your issues.
    Thanks -- Jeff

  • Oracle portal using JSF, JSP, Struts framework

    Hi ,
    Can anyone tell me how to build an oracle portal using JSF,Jsp and Struts Framework.
    Also please provide any manual or documentation for developing oracle portal.
    Thanks in Advance,
    Raghav

    At present, i think the best thing to do is to look at the example provided with the struts-faces integration taglib. I don't know any documentation about it.
    http://cvs.apache.org/builds/jakarta-struts/nightly/struts-faces/

  • Passing date to xcelius dashboard using openDocument.jsp

    Hi.
    I created a xcelsius dashboard that uses WEBI report through live-office connection. this dahsboard was uploaded to BO server (InfoView), and I am using openDocument.jsp to view it. ht ejsp gets parameters that I use to set prompts.
    Well, for numbers and strings it works fine, but when I try to pass dates, I get the following error:
    I am using Xceslis 2008
    Cannot Access External Data
    For input string: "31/12/2010" (LO 26000)
    I am using the following URL to open the document:
    http://nextgen-zone:4400/OpenDocument/opendoc/openDocument.jsp?sKind=flash&sRefresh=Y&sDocName=AOF_test_XCLSS_2&sPath=[Help]&lsSK4=2&lsSK1=1&lsSK2=Udiii
    The parameters are passed to some cells in the excel sheet (using Flash Variables in the Data Manager), and it then passed to the Live Office using "Modify Object" -> Prompt Setting.. and then selecting "Choose Excel data range" and selecting some  cell (from the Live Office menu in excel).
    I put some "debug" table in the dashboard, and I see that the date is passed OK to the sheet, therefore, I think that the problem is when the parameters values are passed to the WEBI/Live Office from the sheet, and not from the jsp to the dashboard.
    How can this issue be solved ?
    Thanks  a lot,
    Ehud.

    Try to bind a constant value (same as the one you pass over the flash variable) to the parameter of your LO connection and see if it works. I do believe that the value passed can be a problem here (you may need a key and not the descriptive value).
    Regards,
    Stratos

  • How can I use 1 JSP for edit/create functionality?

    Hi All,
    Does anybody have an example of using one JSP for both editing and creating an object? I am pretty sure I can handle most of it, but am not sure about how I can specify different messages from the resource bundle (i.e. modifying the screen title for the different uses, "New Campaign" vs. "Edit Campaign").
    My background is in PHP and DHTML (i.e. more front-end) and I'm just starting with Java and JSF. As such, I want to be sure that I'm using appropriate patterns for my programming.
    Thank you in advance for any help,
    Matt

    I make the difference between modifying an existing object and a new one by the ID in the object. Each object has a unique ID in my app assigned by the database. So if the ID is 0, the user is creating a new object, not stored in the DB yet. I store the object to be edited/modified in the session before displaying the page:
    For the title:
    <h:outputText value="Edit Material" rendered="#{sessionScope.selectedMaterial.materialId != 0}"/>
    <h:outputText value="New Material" rendered="#{sessionScope.selectedMaterial.materialId == 0}"/>For the action buttons:
    <h:commandButton value="Update Material" action="#{MaterialControllerBean.updateMaterial}" rendered="#{sessionScope.selectedMaterial.materialId != 0}"/>
    <h:commandButton value="Create Material" action="#{MaterialControllerBean.createMaterial}" rendered="#{sessionScope.selectedMaterial.materialId == 0}"/>

  • What is the use of jsp when compare with Struts

    what is the use of jsp when compare with Struts

    JSP Tag Libraries are great for reusable content formatting and ligic.
    For example, let's say you have this Shopping site. Each item you sell is stored in a database, and you get them out depending on Catagories, creating a List of ItemBeans. You allways want to display the items with a catagory header, then a <table> with the item number, the description and the price.
    Instead of creating a bunch of logic in the JSP that does this, you can pass it on to a Tag that might look like this in your JSP:
    <shopping:itemTable catagory="${selectedCatagory}" items="${itemsForCatagory}" />
    This would make the JSP easier to read and work with.
    The actual uses are incredible. Have you used the <jsp:useBean ...> tag? That is an example of a use of the Custom Tag Libraries.
    Furthermore, look into JSTL (JSP Standard Tag Libraries). They are a collection of tags (API by Sun, coding by Apache) used to do many of the standard actions you might want/need to do in JSPs, like a conditional tag (c:if only do something if the test is true), multiple-conditional tags (c:choos c:when c:otherwise) like an if [else if] else construct. Looping through an array or Collection (c:forEach), storeing values in scopes (c:set) formating numbers and dates (the fmt library), xml transformations (xml library), and lots of other things that you could replace scriptlet code with.

  • Can any one tell me how param is used in Jsp:setProperty ?

    Hi Can anyone please explain me with example how param attribute is used in <jsp:setProperty>?
    I have gone through the java doc but it still not clear to me....

    Try the [JSP syntax reference|http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#8856]
    It is very rare that you would use the param attribute, as most times you have your incoming parameter and bean property having the same name.
    Example:
    Say you navigate to http://localhost:8080/myApp/myPage.jsp?username=Bob
    That sends a request parameter "username" with the value "Bob"
    If we have a bean which also has a property username (getUsername(), setUsername()) (ie the property and the parameter have the same name) you can use the following jsp code:
    <jsp:useBean id="user" class="com.mypackage.User"/>
    <jsp:setProperty name="user" property="username">Translates approximately into
    User user = new User();
    user.setUsername(request.getParameter("username"));If instead the bean had a property "username" but the parameter was "userId"
    <jsp:useBean id="user" class="com.mypackage.User"/>
    <jsp:setProperty name="user" property="username" param="userId">
    User user = new User();
    user.setUsername(request.getParameter("userId"));Cheers,
    evnafets

  • Help! can i get a tree view component used in jsp ,urgent!!

    hello all
    can i get a tree view component can be used in jsp ,it gets children data from database only when user expand one node, and it must be able to add nodes or removes node by user,so i can do some post handler in my database.
    regards!

    Where did you get this tree view component?

  • Using precompiled JSPs on Sun ONE 6.1 SP5

    I"m using precompiled JSPs on Sun ONE 6.1 SP5. I have created a virtual server which has one web application deployed as the default web application located at <server-instance>/webapps/myapp. So in the server.xml it appears as :
    <webapp uri="/" path="<server-instnce/webapps/myapp"
    I have precompiled the JSPs using the jspc tool and created the directory containing the class files and have put them under WEB-INF/classes directory. I also generated the web.xml file with mappings for all jsps.
    My problem is that in my web.xml I have specified the <welcome-file> as index.jsp which used to reside under the <server-instance>/webapps/myapp directory. but now since i'm using precompiled versions i have physically removed that file. And now when i point my browser to the app's URL in the browser, i get the app's directory structure and only when i explicitly point my browser to https://<ip>:port/index.jsp then only the index.jsp page is invoked. I'm confused with this behavior. Do I need to change my docsroot directory to point to where the jsp class files are stored? I dont know what else can be going wrong...
    Any help appreciated :D
    Thanks

    Okkay i'll make my question easier.. if i'm using precompiled JSPs i.e. all compiled JSP files (.class files) including index.jsp is in the WEB-INF/classes directory then what is our docroot property supposed to be. Since if I give the document root as <server-instance>/webapps/myapp then it doesnt show the index.jsp that its supposed to when i point my browser to https://<host>:port. Only when I do https://<host>:port/index.jsp the index.jsp servlet is called and the index.jsp page is rendered.... I removed all the jsps physically from my apps folder but when I put only index.jsp there then it does work properly.... so any thoughts on this anyone...

  • Images used by jsp's

    Is it a good idea to include image resources (like .gif and .jpg) used by jsps into the web.xml file? If so, how or what is the best way to include such resources in the web.xml file?
    Thanks in advance, Ali

    What exactly are you trying to do?

  • How to "Performing an Action on Multiple Selected Records" using Struts-JSP

    Hi all:
    How to do "Performing an Action on Multiple Selected Records" through using Struts/JSP solution that is original MVC/UIX customizing example by Jheadstart.
    I know how to reason by analogy through tutorial guide on
    Model and Control layer of MVC , but for View layer that is torment to me !
    have any idea ?
    thanks a lot .

    Ting Rung,
    In the table in the JSP page you add a checkbox like this:
    <td class="fixed">
    <input type="checkbox" name="multiselect" value="<%=index%>"/>
    </td>
    This will render a checkbox in each row, with index number of that row as value.
    When you submit the page the request contains the multiselect parameter when at least one row has the checkbox checked.
    You can get the value of the multiselect parameter by calling sessionData.getRequestParameterValues("multiselect") in your action. The value is a string array containing the index numbers of the rows that have the checkboc checked.
    Steven Davelaar,
    JHeadstart Team.

  • What is the best editor to use for JSP/Servlet?

    Hello,
    What is the best editor to use for JSP/Servlet database development.
    I'm looking at Dreamweaver,Java Studio Creator.
    I want some thing fairly easy to use that has database helper wizards like dreamweaver.
    Thanks for the help.
    Frank

    Is it better to have a servlet do the database work and call it from JSP?No, it's better to have persistence objects do the database work. Servlets handle HTTP requests, and JSPs are HTML factories that should be pure view.
    But there are lots of ways to do things. You just have to understand the tradeoffs when you decide.
    I do not want to hammer out code, I want to learn the
    best way to do things from experienced developers. Sorry, sounded like you just wanted to churn stuff.
    "best way" can be subjective. In one app, "best" might be "delivered fastest". For another, "best" might be "most secure" or "most easily modified" or "best performing" or whatever. You won't get a "best" answer, only different choices. And they aren't always so easy to explain or execute.
    I'd recommend that you start by reading about layered applications (3-tier architectures) and MVC separation. Once you've Googled enough about that, look into a framework like Struts or Spring or WebWork. That'll help you figure out where to put each responsibility in your app.
    I can use dreamweaver to create web apps, but I hate
    the arrays used to define fields. It also seems not
    to take advantage of connection pooling.Don't know what you're talking about here, Frank. What do fields have to do with connection pooling?
    %

Maybe you are looking for