Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp 访问sql:param中的c:var变量_Jsp_Jsp Tags - Fatal编程技术网

Jsp 访问sql:param中的c:var变量

Jsp 访问sql:param中的c:var变量,jsp,jsp-tags,Jsp,Jsp Tags,我在访问jsp“sql标记”中的jsp“核心标记”进行查询时遇到了问题 代码: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> <sql:setDataSource var="myDS" driver="org.postgresql.

我在访问jsp“sql标记”中的jsp“核心标记”进行查询时遇到了问题

代码:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> 

<sql:setDataSource
    var="myDS"
    driver="org.postgresql.Driver"
    url="jdbc:postgresql://localhost:xxxx/xyz"
    user="xyz" password="test123"
/>
<% String user_Email = session.getAttribute("email").toString(); 
   out.println("Email = "+ user_Email); %>
  <c:set var="emailid" value= "${user_Email}"/>

<sql:query var="listUsers"   dataSource="${myDS}">

    SELECT * FROM developer_apikey_registration where email_id = ?  ;
    <sql:param value="${emailid}"/>


</sql:query>

从开发者注册中选择*,其中email\u id=;
我无法在此处获取电子邮件值。尽管我在session属性中检查了它是否正确

请在这方面帮助我。我不熟悉JSP 提前谢谢。

试试这段代码

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> 
<sql:setDataSource
    var="myDS"
    driver="org.postgresql.Driver"
    url="jdbc:postgresql://localhost:xxxx/xyz"
    user="xyz" password="test123"
/>
  <c:set var="emailid" value= "${sessionScope[user_Email]}"/>
<sql:query var="listUsers"   dataSource="${myDS}">
    SELECT * FROM developer_apikey_registration where email_id = ?  ;
    <sql:param value="${emailid}"/>
</sql:query>

从开发者注册中选择*,其中email\u id=;
希望这有帮助


    <%String pkgName=null;%>
    <%String apiKey=null;%>
    <% String user_Email = session.getAttribute("email").toString(); 
       String email = null;
     if(session.isNew())
        {
             RequestDispatcher rdp=request.getRequestDispatcher("index.jsp");
             rdp.forward(request, response);
        }
    %>
   <%= user_Email %> // To check if email is not null

    <div align="center">
    <table border="1" cellpadding="5">
        <caption><h2>List of users</h2></caption>
        <tr>
            <th>Email</th>
            <th>Package Name</th>
            <th>API Key</th>
            <th> Operation </th>
        </tr>


  <%
       try
       {
         Connection con=DbConn.getConnect();
         Statement st=con.createStatement(); 
         String q1="select * from  developer_apikey_registration where email_id ='"+user_Email+"'";
         ResultSet rs1=st.executeQuery(q1);

         while(rs1.next())
                {

                   email = rs1.getString("email_id");
                   pkgName = rs1.getString("package_name");
                   apiKey = rs1.getString("apikey");
                   %>

                   <tr>
                <td><%=email%></td>
                <td><%=pkgName%></td>
                <td><%=apiKey%></td>
                <td><input type ="button" name="editBtn" id ="edtBtn" value="Edit">
        <input type ="button" name="deleteBtn" id ="delBtn" value="Delete"> </td>
            </tr>
    <%               
                }

       }  
       catch(Exception e)
               {
                e.printStackTrace();
           }


    %>

   </table>
</div>
//检查电子邮件是否不为空 用户名单 电子邮件 包名 API密钥 活动
您是否检查了堆栈跟踪(我指的是您的服务器日志)以及是否为jstlNo error添加了标题?没有错误,我使用硬编码的值进行了检查,at为我提供了预期的输出。我已经将核心库放在类路径中,并且它工作正常。这个代码是否
out.println(“Email=“+user\u Email”)打印值是的,它打印输入的文本。它将打印在浏览器本身上。然后问题是您没有以正确的方式设置值,请尝试我的codeChecked,仍然无法工作。。。。同样的问题,我看不到电子邮件被分配到sql参数。我在服务器上也没有看到任何错误。任何异常。请检查您的jspNo中是否有类似于此
指令的内容,如果我将使用该指令,那么我将如何在上述代码中获取session.getAttribute(“email”)值。。。。没有提到这样的事。默认情况下,它是true。即使在这种情况下,它对getAttribute也不起作用。接下来要检查EL是否为您工作,请检查打印
${sessionScope[user\u Email]}“