JSP :: Assigning Session Variable In Query Syntax

Jan 9, 2015

In my JSP I need to retrieve some data from MySQL. I need to assign a "email" variable to the "WHERE" clause. The variable is retrieved from the session attribute. So far, I have this code:

<sql:query dataSource="${user}" var="result">
SELECT * from users where email = ${sessionScope.email};
</sql:query>

It doesn't work.

View Replies


ADVERTISEMENT

Servlets :: Restoring Session Variable After Timeout

Oct 17, 2014

My application uses Struts and IBM Web application Server. I have a question regarding session management. I have a variable stored in session scope, i.e. the name of the client. it is a intranet application. Now whenever the user leaves the browser screen for a long time, the session times out and losses the name of the client.

How to restore the variable after the client comes back and starts using the browser and refreshes the screen and starts using the application. I want just the browser to remember the session variable i.e. "name" of the client.

View Replies View Related

Servlets :: Java Class - Session Variable Error

Dec 14, 2014

My dynamic web project has a java class that captures a session variable with the following code.

HttpSession LoginSession = request.getSession();
String VAR = LoginSession.getAttribute("myVar").toString(); //This is the row 127

If i test the app in local (Mac + Java 1.8 + Tomcat 8) all works. In my remote cloud server (Ubuntu 14.10 + Java 1.8 + Tomcat 8) all works, except this class, that has this code. I copy the complete error here. Note that the row 127 of the error message is the second row of the previous code; and, if i comment this row with // and assign a fix variable all works. So, the problem is that 127^ row.

14-Dec-2014 08:15:23.923 SEVERE [http-nio-8080-exec-14] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [srvNavigation.SrvPT] in context with path [/myapp] threw exception
java.lang.NullPointerException
at srvNavigation.SrvPT.doGet(SrvPT.java:127)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)

[Code] ....

How can i solve the problem?

View Replies View Related

JSP / JSTL :: Page Logout - Invalidate All Session Variable

Apr 17, 2013

I have index.jsp in that page logout is available. while hitting the button . i want to invalidate all the session variable which i used. but it is not happening.

<html:image src="/x/images/logout1.png" onclick="logout()"> </html:image><script type="text/javascript">     
               function logout() {
               document.forms[0].action =  "/x/x.do?method=dologout";
            document.forms[0].submit();
             
[Code] .....

Even when i logout. then i start from new session means., session values continues from previous session. not killed.

View Replies View Related

PreparedStatement For MySQL Query - Where Query Seems To Get Cut Off

Mar 21, 2014

I am having a problem with a PreparedStatement for a MySQL query, where the query seems to get cut off. I can't really post a self contained example, because it involves an SQL database.The part of the code with the problem...

Java Code:

public void insertEntry(
Hashtable<String, String> strings,
Hashtable<String, Integer> integers,
Date created, Date paid, boolean enabled)
throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");

[code]....

The output of the whole program, though all it has done so far is create some default values and attempt to insert them with the above code, where the problem occurs.

Debug: SQLpaid = 1990-03-21

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorEx ception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT enabled=0, username='default_username', created='2000-03-21', paid='1990-' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)

[code]....

View Replies View Related

JSP :: Page Directive Attribute Session False - Yet Session Created

Feb 26, 2014

May be I did not understand the meaning and usage of attribute "session" in page directive. My understanding is if session=false, in page directive, then the JSP page will not participate in the session. However, I have my welcomepage as below:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
........
.......
<%= session %>
<c:out value="${pageContext.request.session}"/>

if I choose session=true, then both ways of accessing session works , which means the JSP page participated in the session.

But if I change the session=false, then <%= session %> fails, but <c:out value="${pageContext.request.session}"/> does not fail.

how can c:out still show the session, when session = false

View Replies View Related

Servlets :: Can Access Session Object Even Session Is Time Out

Jun 4, 2014

Can I access the session object even session has been expired? I need to check whether session is expired or not for each request.The session invalidation is set null the session object. What I concluded, session time out I can access session object but session invalidation I can not access session object. How can I find the session time out by using session object?

View Replies View Related

Web Services :: Rest Session Not Getting Invalidated After Invalidating UI Session?

Dec 17, 2014

I have 2 war in 1 EAR.

War A corresponds to UI

War B corresponds to Rest

1) From War A, I login to the application and then fetch some users that is a rest call. I get the response back from rest in json form that ui consumes and display the data on page.

2) Now I click on the logout link from ui jsp. This logs out the session from Ui. I use <form data-dojo-type="dijit/form/Form" based logout.

3) I then go to the proxy (using burp) and manually request the rest call which I made in step no 1), the rest gives the response back with the same json object returned in step no 1) This shows that the logout action on step 2) is invalidated the session from War A (ui war) but the session or cookie based from WAR B (rest war) is not invalidated.

Expected outcome:After I Logout from War A(ui war), the session must also get invalidated from war B (rest war) and manually request from proxy should not get the same response object as received in step 1)

View Replies View Related

Servlets :: Updating Session Value But Same Session In JSP Page Not Updated

Jul 8, 2014

I am developing a e-commerce college project, here i add the items in the cart(a div tag in the jsp page) via servlet by creating sessions,

flow control: shopping jsp (when user wants to add an item in the cart) --> item servlet (which is used to create session and synchronized it) --> cart servlet(which is used to add items in the arraylist and show them in the shopping.jsp's div tag + it also sets the total purchase amount in the session variable "totalpurchase")

now after that user wants to proceed to checkout, here i use the onclick event to check the minimumshopping amount must be less than the totalpurchase (totalpurchase which i had setted in the session),but my jsp page is unable to rechognise the updated value of the totalpurchase, yes, if i reload the page, it rechognises the new updated value of the totalpurchase? but i want it to rechognise the updated total purchase value, without reloading he jsp page..

View Replies View Related

Assigning Random Int To Strings

Jun 16, 2014

while (gamesPlayed<gameQty) {
userChoice = JOptionPane.showInputDialog("Rock, Paper, or Scissors?");
//Determine winner for each game
if (compChoice.equalsIgnoreCase(userChoice));

[Code] ....

It seems to circle through the loop gameQty times, without comparing.

View Replies View Related

Int Declarations - Assigning Length And Width

Mar 19, 2015

What is happening in below mentioned java code. Why in method insert, int l, int w is declaring & it is assigning to length & width.

class Rectangle{
int length;
int width;
void insert(int l,int w){
length=l;
width=w;

[Code] ....

View Replies View Related

Trying To Initialize Arrays - Assigning Variables

Apr 1, 2014

I'm making a card game and have a class I used to assign all my card variables.

However, it's giving me multiple errors and I can't seem to be able to access the variables from my other classes.

Java Code:

package com.summoners.Screen;
class Cards {
public static String[] names;
name = new String[1000];
atk = new int[1000];

[Code] .....

View Replies View Related

Calling Out Constructor And Assigning Values To It From A Scanner

Oct 16, 2014

import java.util.Scanner;
public class Try{
static String name;
static int age;
static Scanner a = new Scanner(System.in);
static Scanner b = new Scanner(System.in);
static Scanner c = new Scanner(System.in);
public Try(String name, int age){

[Code] ....

I was trying to make a program that asks the user to create a person or a group of persons and assign names and age to them. So I made a constractor "Try" and a method "AskUser".in AskUser() I use a do/while loop where user is asked to input a name, an age and if he likes to create another person. Now how do I take the input data each time the loop runs, and send it to constractor to create new objects with it? And how these new objects will be called?

View Replies View Related

Assigning Private Variables Values From Constructor

Jun 13, 2014

I am able to get output from my constructor when I place a loop inside of it. However when I try to access the private variable that I thought was set by the constructor I get nothing. When I check its size it is zero as well.

Java Code:

public class WinningHand extends PokerCalculator {
private int p1Size;
private int p2Size;
private String[] p1Hand = new String[p1Size];
private String[] p2Hand = new String[p2Size];

[Code] ....

View Replies View Related

JDialog - Assigning ActionListener To Buttons And Fields

Apr 27, 2014

I have a program that using one JFrame which opens one of two JDialog windows depending on which button is pressed.

How do I assign listeners to the buttons and fields on the JDialog window? I added listeners on the View end, but how do I process them? I tried adding the '..implements ActionListener" class in the main Controller but it does not recognize/hear anything.

View Replies View Related

Accepting And Assigning User Input Into Multidimensional Array?

Apr 7, 2014

I have been asked to write a library program that will keep record of books and the year it was published. The program should ask the user how many rows he wants accept the string input from the user and display them in rows and columns. This is how i code it

package multidimension;
import java.util.Scanner;
public class bookrecords {
public static void main(String[]args){
//declaring a scanner variable
Scanner input =new Scanner(System.in);

[code]....

View Replies View Related

Assigning Empty Score To Strings In Text File

May 27, 2014

I have a txtfile which I read and go through. My question is what are the ways I could do to read a txtfile of words and assign an empty score to each of the word in it. So each word will have a 0 value. Later on I will manipulate the score but for now I want each word to have a 0 score.What I have at the moment is reading a text file full of words eg:

private void readtextfile() {
try {
Scanner rd = new Scanner(
new File("filename"));
List<String> lines = new ArrayList<String>();
while (sc.hasNextLine()) {
lines.add(sc.nextLine());

[code]...

how to make each of the words to have a score of zero 0?

View Replies View Related

Assigning Int Literal To Byte Works But Not As Method Parameter

Apr 23, 2014

If you write

byte b = 100; it works (implicit conversion of implicit int literal 100 to byte.

But if you have a methodvoid bla(byte b){}

And want to invoke it with a literal (which is an int by default):bla(8) then there is no implicit conversion.

Is the byte b = 100; just an exception in Java? And is it the rule that one has to explicitely cast (narrow) integer literals when passing to smaller-than-int types?

View Replies View Related

Android - Looping Through Parse Data / Assigning To ArrayAdapter

Apr 24, 2015

I am looping through data in Android, using Parse data. I came up with this as a way to get user information; the larger goal is to create a model of data that I can use in an array adapter, so I can create a custom list view (as described here [URL] .... In the example, the data are hard-coded, not pulled from a database.

public static ArrayList<Midwifefirm> getUsers() {
//Parse data to get users
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.orderByAscending(ParseConstants.KEY_PRACTICE_NAME);
query.findInBackground(new FindCallback<ParseUser>() {

[Code] ....

The intention is that for every user that does not have the type patient, collect this data about them, then store it in the arrayList.

On the return statement, though, there is an error: cannot return a value from a method with a void return type.

I may be over complicating this...read through various sources to get a model for this...in the end, I want to display a list of information about specific users, after the user makes a selection of a city...it would therefore display all the information about the medical practices in that city.

View Replies View Related

Vararg Syntax - Using Three Dots Only?

Aug 15, 2014

why we use only three dots(...) in vararg method???

View Replies View Related

Syntax For Array Of Objects

Apr 10, 2014

I know the first line below creates an object but the second line creates an array of cars, I'm just not sure how it does that. I can see sportsCar is one object in the array but the others are written in a different way. It seems there should a couple names there instead. Please explain the syntax in this code that's highlighted. I don't know how to make sense of it and I've read through the book where I got it where it explained creating objects.

Auto sportsCar = new Auto("Ferrari", 0, 0.0);
Auto [] cars = {new auto("BMW", 100, 15.0), sportsCar, new Auto()};

View Replies View Related

Syntax Highlighting In Editor?

Jun 11, 2014

Here is the original code I found on StackOverFlow. It highlights some specific words in a JTextPane.

import javax.swing.*;
import java.awt.*;
import javax.swing.text.*; 
public class ColorChangeWhileTyping extends JFrame{
private int findLastNonWordChar (String text, int index) {
while (--index >= 0) {
if (String.valueOf(text.charAt(index)).matches("W")) {

[code]....

I dont know for some reason it doesnt work correctly. The colour goes away after I press Space to write the next word.

View Replies View Related

If Statement Syntax Error

Dec 13, 2014

This is what i have so far, I use BlueJay to write this:

import javax.swing.JOptionPane;
public class payroll
{
String again = y;
//
private String name;
private double rate;
private double hours;
static double gross; //gross pay

[code]....

my first problem is that it expects a ")" on this line :"if ((hours <=40)rate *1);"For the assignment itself these are the requirements:

-Create a class called payroll with private variables for rate hours and name

-Create static variables for gross pay, union dues, health coverage (hp in my case), FICA taxes, State taxes, Federal taxes, net pay, all must be initialized to 0

-default constructor that assigns default values

a function called calcPay that will do the following tasks and print it to a pay stub :

- function that checks the hours ( if hours are 40 or less pay rate, if over 40 pay 150% of the rate)
- calculates gross pay before any deductions (using user inputted hours and rate)
- deduct medical coverage and union dues from gross pay and call this adjusted gross pay (also this should have its own line on the paystub)
- A function that deducts State, federal and fica taxes from adjusted gross
- FICA - 7% for any income
-Federal - 2% for $0-$150 / 6% for 150.01 - 300 / 14% for 300.01 - 600 / 18% for 600.01 - unlimited
-State - 1% for 0-150/ 3% 150.01 - 300 / 5% 300.01 - 600/ 8% 600.01 - unlimited
- amount after all deductions is the net pay ( show this amount on its own line)
- Start a loop that asks each time if there are more employees (y/n) y should continue the program and n should end it
-dialog boxes should be created to recieve values for name, hours and rate
- if the rate is entered below $8 dollars a new box should pop up and ask for a higher value
- When there are no more employees, print out a summary of quantities stored in static variable (also had a problem with this)
- End

So I think i completed most of these objectives but am having trouble with the syntax and some of the objectives

View Replies View Related

Syntax Error On Token

May 12, 2014

So my only error in the entire code is on the 9th line of this code sample. It says "Syntax Error on token "new", @ expected" but @ does not belong there, as far as I can tell, since the error does not go away upon adding it.

public class Obstapacalypse implements KeyListener, ActionListener {
private static final String EXIT_ON_CLOSE = null;
private JFrame frame;
private Player player = new Player();
private JPanel contentPane;
private JButton btnStart;

[code]....

View Replies View Related

JSP :: Query String URL

Apr 10, 2014

how this query string will be prnted it is not showing me the psid values.

<tr bgcolor="pink" >
<td><%=resultSet.getString("FirstName") %></td>
<td><%=resultSet.getString("LastName") %></td>
<td><%=resultSet.getString("Username") %></td>
<td><%=resultSet.getString("Password") %></td>
<td><%=resultSet.getInt("Psid")%></td>
<td><a href="Edit.jsp?psid="<%=resultSet.getInt("Psid")%>>Edit</a></td>
<td><a href="Delete.jsp">Delete</a></td>
</tr>

View Replies View Related

Find Whole Syntax Of API Method Online?

Jul 5, 2014

I was trying to find the complete readLine() method In the online docs but all I can get hold of Is:

readLine
public String readLine()
throws IOException

Reads a line of text. A line is considered to be terminated by any one of a line feed

('
'), a carriage return ('
'),

or a carriage return followed immediately by a linefeed.

Returns:A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reachedThrows:IOException - If an I/O error occursSee Also:Files.readAllLines(java.nio.file.Path, java.nio.charset.Charset)

Is It possible to view the actual method syntax online ?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved