Sample Java applet code with canvas and input fields simultaneously working
I am developing an application for a calculator using Java applet where in the applet window, one half will contain two text boxes (named "first num...More
I am developing an application for a calculator using Java applet where in the applet window, one half will contain two text boxes (named "first number" and "second number") which will take two integers ,two check boxes (named "add" and "subtract") where user can select operations of his choice and a "calculate" button.
When "calculate" button will be pressed after giving required inputs, result will be shown in the other half of applet window. Someone please help me with a sample code for this applet.
I am new in Java applet. Please help me.
|
Returning the position in list in Android with OnClickListener on Button
I have looked over the internet and must be missing something. My task seems simple and I have found a few other post like it but I have yet to be a...More
I have looked over the internet and must be missing something. My task seems simple and I have found a few other post like it but I have yet to be able to get mine to work. The following is my code (sorry I'm new to java and android so if I have done some things that are not best practice I apologize.) Anyhow my situation,
I have a listView that populates a few text fields from a Database, at the right side of these text boxes I have created a delete button and would like for that record (row) to be deleted when the corresponding delete button is pressed. I have successfully created an OnClickListener for my button but am unable to obtain the position in the list view that the button has been clicked.
---------------------------------------------------
TextView TextView | Delete Button
---------------------------------------------------
TextView TextView | Delete Button
---------------------------------------------------
Code:
public class CalcCursorAdapter extends SimpleCursorAdapter implements Filterable{
private Context mContext;
private ListView mListView;
private int mLayout;
protected static class ViewHolder {
protected TextView text;
protected ImageButton button;
private int position;
}
@SuppressWarnings("deprecation")
public CalcCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)
{
super(context, layout, c, from, to);
this.mContext = context;
this.mLayout = layout;
//mListView = .getListView();
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView summary = (TextView)view.findViewById(R.id.calctvPrice);
TextView savings = (TextView)view.findViewById(R.id.calctvSavings);
summary.setText(cursor.getString(cursor.getColumnIndexOrThrow("qcFinalPrice")));
savings.setText(cursor.getString(cursor.getColumnIndexOrThrow("qcSavings")));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
ViewHolder holder = new ViewHolder();
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.calc_list_item, parent, false);
holder.button = (ImageButton) v.findViewById(R.id.qcbtnDelete);
holder.button.setOnClickListener(deleteButton);
bindView(v, context, cursor);
v.setTag(holder);
return v;
}
private OnClickListener deleteButton = new OnClickListener() {
public void onClick(View v){
Toast.makeText(mContext.getApplicationContext(), "test", Toast.LENGTH_SHORT).show();
}
};
public long qcItemId(int position) {
return position;
}
}
I have looked at many examples and a lot of the time they look to be for Array adapters, The other thing that I have found is some people will override the getView function and I was under the impression that you could perform said task without doing that. Also, I don't want the list item iteslef to be clickable, just the button... it seems like it should be such a simple question but I have been looking... I apologize if this is covered well somewhere and I have just missed it, I have spent the last 4 hours searching the web trying to find a fix!
Anyhow, Any help would be very much appreciated!
Thank You.
|
javax.security.auth.login.LoginException: No LoginModules configured for SomeLogin
Well I'm trying to create JAAS authentication for my Servlet (running on Tomcat 7 in Eclipse), but I'm getting this error.
He're's the compl...More
Well I'm trying to create JAAS authentication for my Servlet (running on Tomcat 7 in Eclipse), but I'm getting this error.
He're's the complete stack trace:
'`
INFO: Starting Servlet Engine: Apache Tomcat/7.0.32
Geg 19, 2013 9:53:08 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Geg 19, 2013 9:53:08 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Geg 19, 2013 9:53:08 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1786 ms
Geg 19, 2013 9:53:30 PM org.apache.catalina.realm.JAASRealm authenticate
SEVERE: Unexpected error
javax.security.auth.login.LoginException: No LoginModules configured for GdiaLogin
at javax.security.auth.login.LoginContext.init(Unknown Source)
at javax.security.auth.login.LoginContext.<init>(Unknown Source)
at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:392)
at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:332)
at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:158)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Geg 19, 2013 10:29:20 PM org.apache.catalina.realm.JAASRealm authenticate
SEVERE: Unexpected error
javax.security.auth.login.LoginException: No LoginModules configured for GdiaLogin
at javax.security.auth.login.LoginContext.init(Unknown Source)
at javax.security.auth.login.LoginContext.<init>(Unknown Source)
at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:392)
at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:332)
at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:158)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
`
In context.xml:
<Realm className="org.apache.catalina.realm.JAASRealm"
appName="GdiaLogin"
userClassNames="org.ktu.gdia.core.security.UserPrincipal"
roleClassNames="org.ktu.gdia.core.security.RolePrincipal" />
In jaas.config (I'm pretty sure Tomcat finds it correctly because I added the correct path with arguments for "run configurations" in eclipse):
GdiaLogin {
org.ktu.gdia.core.security.GdiaLoginModule required debug=true;
};
I'm assuming there has to be something wrong with the jaas.config...
My Login Module, not sure if I need to provide it here, though, it's almost straight from a tutorial I've been following:
package org.ktu.gdia.core.security;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
import org.ktu.gdia.core.businesslogic.ControllerFactory;
import org.ktu.gdia.core.interfaces.SecurityControllerInterface;
public class GdiaLoginModule implements LoginModule {
private CallbackHandler handler;
private Subject subject;
private UserPrincipal userPrincipal;
private RolePrincipal rolePrincipal;
private String login;
private List<String> userGroups;
private SecurityControllerInterface securityController;
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map<String, ?> sharedState, Map<String, ?> options) {
try {
securityController = ControllerFactory.getInstance().getSecurityController();
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException e) {
throw new RuntimeException("Failed to initialize SecurityController in " + this.getClass().getSimpleName(), e);
}
handler = callbackHandler;
this.subject = subject;
}
@Override
public boolean login() throws LoginException {
Callback[] callbacks = new Callback[2];
callbacks[0] = new NameCallback("login");
callbacks[1] = new PasswordCallback("password", true);
try {
handler.handle(callbacks);
String name = ((NameCallback) callbacks[0]).getName();
String password = String.valueOf(((PasswordCallback) callbacks[1])
.getPassword());
// Here we validate the credentials against some
// authentication/authorization provider.
// It can be a Database, an external LDAP,
// a Web Service, etc.
// For this tutorial we are just checking if
// user is "user123" and password is "pass123"
if (securityController.credentialsValid(name, password)) {
// TODO authenticate
login = name;
userGroups = new ArrayList<String>();
userGroups.add("admin");
return true;
}
if (name != null &&
name.equals("user123") &&
password != null &&
password.equals("pass123")) {
// We store the username and roles
// fetched from the credentials provider
// to be used later in commit() method.
// For this tutorial we hard coded the
// "admin" role
login = name;
userGroups = new ArrayList<String>();
userGroups.add("admin");
return true;
}
// If credentials are NOT OK we throw a LoginException
throw new LoginException("Authentication failed");
} catch (IOException e) {
throw new LoginException(e.getMessage());
} catch (UnsupportedCallbackException e) {
throw new LoginException(e.getMessage());
}
}
@Override
public boolean commit() throws LoginException {
userPrincipal = new UserPrincipal(login);
subject.getPrincipals().add(userPrincipal);
if (userGroups != null && userGroups.size() > 0) {
for (String groupName : userGroups) {
rolePrincipal = new RolePrincipal(groupName);
subject.getPrincipals().add(rolePrincipal);
}
}
return true;
}
@Override
public boolean abort() throws LoginException {
return false;
}
@Override
public boolean logout() throws LoginException {
subject.getPrincipals().remove(userPrincipal);
subject.getPrincipals().remove(rolePrincipal);
return true;
}
}
Well? Any ideas?
|
Java - Equations Solver Library
Is there any library which can solve simple stuff like
"2x = 8"
"x + x = 12"
This question has been asked so many times but I didnt found any solu...More
Is there any library which can solve simple stuff like
"2x = 8"
"x + x = 12"
This question has been asked so many times but I didnt found any solution...
Thx in advance
|
Back out of a directory for a URI in java
I'm trying to make an app that opens a static webpage. Just a pilot for a bigger project. At the moment I'm getting the default browser to open fi...More
I'm trying to make an app that opens a static webpage. Just a pilot for a bigger project. At the moment I'm getting the default browser to open fine and the test page loads up. However, it will only work if the html file is in the directory as the .class file. How can I back out of the directory the class file is in and enter another directory? Similar to a cmd cd ....\whatever command.
Thanks
|
NullPointerException on Null Check
I am messed up with the below Code Cannot able to distinguish between the two code Snippets:
String Check=null;
if(Check!=null &...More
I am messed up with the below Code Cannot able to distinguish between the two code Snippets:
String Check=null;
if(Check!=null && Check.isEmpty()){
System.out.println("Get Inside");
}
Above Code works Fine and Print the Message.
if(Check==null && Check.isEmpty()){
System.out.println("get Inside")
}
this code will throw the NullPointerException.Not able to distinguish between this Code Please Help.
|
Determining pending buffered write size with netty?
I have a daemon I'm writing and I want it to fill up the TCP send buffer but once it is filled I want it to suspend writing to the connection.
... More
I have a daemon I'm writing and I want it to fill up the TCP send buffer but once it is filled I want it to suspend writing to the connection.
I'm using Netty 3.2.5 ...
The idea is that all writes should go into the TCP send buffer until that fills
Then once that is filled the writer thread should mark the connection as 'suspended' to move on to other clients that are reading fast enough.
The problem is that I can't get it to work.
I wrote an implementation that just called channel.write() and then I had an implementation of isSuspended() that I wrote that called getInterestOps().
Looking at org.jboss.netty.channel.socket.nio.NioSocketChannel ... would confirm that internally it's doing what I expect.
The only problem is that it doesn't work. It drops messages if I do it this way.
This is with a SMALL response of say 40 HTTP chunks which is smaller than the TCP send buffer yet it's still dropping messages.
Is there an accepted way of doing this?
|
Why do C and Java treat the following loop differently [closed]
in C
#include <stdio.h>
int main(){
int x=100;
x=x++ + x++;
printf("x : %d\n",x); // prints 202
return 0;
...More
in C
#include <stdio.h>
int main(){
int x=100;
x=x++ + x++;
printf("x : %d\n",x); // prints 202
return 0;
}
in Java
class Demo{
public static void main(String args[]){
int x=100;
x=x++ + x++;
System.out.printf("x : %d",x); // prints 201
}
}
why these two languages prints different values?what happens 'x=x++ + x++;' line ?
|
`Arrays,copyOf` didn't do a deep copy of objects as it suppose to
I have classBook which can have many Authors. I pass few objects of class Author to the constructor of class ...More
I have classBook which can have many Authors. I pass few objects of class Author to the constructor of class Book then copy these objects by Arrays.copyOF but then if I change any Author data outside the object it will change everywhere so it means the copy has not been created.
I would like to create deep copy. Code is compiling and running with no errors.
import java.util.Arrays;
public class Book {
private String tytul;
private int rokWydania;
private Author[] autorzy;
public Book(String tytul, int rokWydania, Author... autorzy) {
this.tytul = tytul;
this.rokWydania = rokWydania;
this.autorzy = Arrays.copyOf(autorzy, autorzy.length);
}
public String toString() {
String s = " Tytuł: " + tytul +"\nrok wydania: " + rokWydania + "\n";
if(autorzy.length == 1)
s+=" Autor: " + autorzy[0];
else{
s+=" Autorzy: " + autorzy[0];
for(int i = 1; i < autorzy.length; i++)
s+="\n " + autorzy[i];
}
return s + "\n\n";
}
public static void main(String[] args) {
Author a1 = new Author("Isabel", "Allende", 1942);
Author a2 = new Author("Manueala", "Gretkowska", 1964);
Author a3 = new Author("Piotr", "Pietucha", 1954);
Book b1 = new Book("Suma naszych dni", 2010, a1);
Book b2 = new Book("Polka", 2001, a2);
Book b3 = new Book("Sceny z życia pozamałżeńskiego", 2003, a2, a3);
a2.zmienInformacje("Tove", "Jansson", 1956);
Book b4 = new Book("Lato muminków", 2006, a2);
System.out.println(b1);
System.out.println(b2);
System.out.println(b3);
System.out.println(b4);
}
}
public class Author {
private String imie, nazwisko;
private int rokUrodzenia;
public Author(String imie, String nazwisko, int rokUrodzenia) {
this.imie = imie;
this.nazwisko = nazwisko;
this.rokUrodzenia = rokUrodzenia;
}
public String getImie() {
return imie;
}
public String getNazwisko() {
return nazwisko;
}
public int getRokUrodzenia() {
return rokUrodzenia;
}
@Override
public String toString() {
return imie + " " + nazwisko + " (ur. " + rokUrodzenia + ")";
}
public void zmienInformacje(String imie, String nazwisko, int rokUrodzenia) {
this.imie = imie;
this.nazwisko = nazwisko;
this.rokUrodzenia = rokUrodzenia;
}
}
Desired output:
Tytuł: Suma naszych dni
rok wydania: 2010
Autor: Isabel Allende (ur. 1942)
Tytuł: Polka
rok wydania: 2001
Autor: Manuela Gretkowska (ur. 1964)
Tytuł: Suma naszych dni
rok wydania: 2010
Autorzy: Manuela Gretkowska (ur. 1964)
Piotr Pietucha (ur. 1954)
Tytuł: Lato muminków
rok wydania: 2006
Autor: Tove Jansson (ur. 1956)
My output
Tytuł: Suma naszych dni
rok wydania: 2010
Autor: Isabel Allende (ur. 1942)
Tytuł: Polka
rok wydania: 2001
Autor: Tove Jansson (ur. 1956)//WRONG
Tytuł: Sceny z życia pozamałżeńskiego
rok wydania: 2003
Autorzy: Tove Jansson (ur. 1956)//WRONG
Piotr Pietucha (ur. 1954)
Tytuł: Lato muminków
rok wydania: 2006
Autor: Tove Jansson (ur. 1956)
|
I already know the basics of applets, now what?
I have experience in programming or scripting in these languages:
Lua
PHP
GML
Using what I already know about prog...More
I have experience in programming or scripting in these languages:
Lua
PHP
GML
Using what I already know about programming, I decided to learn how to make Java Applets for my website. Now, since I already know a lot about coding I found it relatively easy to learn the basic Java Applet stuff like variables and operators.
I've searched the web for a more in-depth tutorial or explanation of Java Applets but all I seem to be able to find are tutorials on the very basics and the very intermediate stuff.
Where can I go to learn the part of coding with Java that doesn't have to do with the very basics, but something more of my level.
|
Organizing JPanels and Layouts
So I have the following screen:

And this is my code:
s...More
So I have the following screen:

And this is my code:
setLayout(new BorderLayout());
JLabel lblTitulo = new JLabel("Sistema Generador de Examenes");
lblTitulo.setFont(new Font("Tahoma", Font.BOLD, 18));
JPanel panel1 = new JPanel();
panel1.setBackground(Color.white);
panel1.add(lblTitulo);
add(panel1, BorderLayout.NORTH);
JButton btnCrear = new JButton("Crear Examen");
JButton btnRendir = new JButton("Rendir Examen");
JButton btnCorregir = new JButton("Corregir Examen");
JButton btnVerCorrecciones = new JButton("Ver Correcciones");
btnCrear.setBounds(15, 100, 450, 35);
btnRendir.setBounds(15, 150, 450, 35);
btnCorregir.setBounds(15, 200, 450, 35);
btnVerCorrecciones.setBounds(15, 250, 450, 35);
JPanel panel2 = new JPanel();
panel2.setBackground(Color.white);
panel2.setLayout(null);
panel2.add(btnCrear);
panel2.add(btnRendir);
panel2.add(btnCorregir);
panel2.add(btnVerCorrecciones);
add(panel2, BorderLayout.CENTER);
1 - I'm using the BorderLayout. Do I need to have 2 JPanels to separate components (JLabel and JButtons) if I want to have the JLabel in the North and the JButtons in the Center? Or is there any way to use just one JPanel?
2 - I want to take out the setBounds used in my JButtons and use some Layout in order to have my JButtons like that in the middle of the screen. How could I do that?
|
Why does this line of code always give me a null point exception? [closed]
I have tried everything, but everytime I call a SPECIFIC line of code, it ALWAYS returns an error! The code takes an edittext object's .totext().toS...More
I have tried everything, but everytime I call a SPECIFIC line of code, it ALWAYS returns an error! The code takes an edittext object's .totext().toString() and sets a variable equal to it. It than calls a method from another class. These two are simply getter and setter methods. Somehow, they are making my program run into a NullPointerException, and then my program force closes!
Here is my AddNewClass class:
package com.example.schoolhelpertesting;
import android.R.string;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
public class AddNewClass extends Activity {
private String CN = "A";
private EditText ClassName;
private Classes classes;
private Homework hw;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);// Add THIS LINE
setContentView(R.layout.addnewclass);
ClassName = (EditText) findViewById(R.id.ANC);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.addnewclass, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId())
{
case R.id.add:
{
classes.SetValueS(CN);
// hw.SetValuesS();
// hw.AddButton();
finish();
return true;
}
case R.id.Cancel:
{
finish();
return true;
}
}
return false;
}
}
Here is my Classes class:
package com.example.schoolhelpertesting;
public class Classes {
private String ACN[];
private int TCS = 0;
public void SetValueS(String s)
{
ACN[TCS] = s;
TCS++;
}
public String[] GetValueS(String[] s)
{
return ACN;
}
public int GetValueI(int n)
{
return TCS;
}
}
Here is my LogCat:
05-19 15:20:16.958: D/dalvikvm(8933): GC_FOR_ALLOC freed 69K, 26% free 2874K/3871K, paused 38ms
05-19 15:20:17.028: I/dalvikvm-heap(8933): Grow heap (frag case) to 9.586MB for 6984096-byte allocation
05-19 15:20:17.138: D/dalvikvm(8933): GC_FOR_ALLOC freed 1K, 10% free 9693K/10723K, paused 36ms
05-19 15:20:17.238: D/libEGL(8933): loaded /system/lib/egl/libGLES_android.so
05-19 15:20:17.248: D/libEGL(8933): loaded /system/lib/egl/libEGL_adreno200.so
05-19 15:20:17.248: D/libEGL(8933): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
05-19 15:20:17.248: D/libEGL(8933): loaded /system/lib/egl/libGLESv2_adreno200.so
05-19 15:20:17.378: D/OpenGLRenderer(8933): Enabling debug mode 0
05-19 15:20:19.350: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x53d15000 size:14516224 offset:13950976
05-19 15:20:19.350: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x54c8b000 size:15081472 offset:14516224
05-19 15:20:19.350: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x55aed000 size:15646720 offset:15081472
05-19 15:20:19.420: D/memalloc(8933): ashmem: Mapped buffer base:0x54bf3000 size:3768320 fd:71
05-19 15:20:19.450: D/OpenGLRenderer(8933): Flushing caches (mode 0)
05-19 15:20:19.450: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x522d8000 size:3768320 offset:0
05-19 15:20:19.450: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x532a7000 size:7536640 offset:3768320
05-19 15:20:20.601: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x54f8b000 size:14516224 offset:13950976
05-19 15:20:20.601: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x55d63000 size:15081472 offset:14516224
05-19 15:20:20.601: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x56bc5000 size:15646720 offset:15081472
05-19 15:20:21.052: D/OpenGLRenderer(8933): Flushing caches (mode 0)
05-19 15:20:21.052: D/memalloc(8933): /dev/pmem: Unmapping buffer base:0x53d3a000 size:11304960 offset:7536640
05-19 15:20:27.468: D/AndroidRuntime(8933): Shutting down VM
05-19 15:20:27.468: W/dalvikvm(8933): threadid=1: thread exiting with uncaught exception (group=0x40aa6228)
05-19 15:20:27.488: E/AndroidRuntime(8933): FATAL EXCEPTION: main
05-19 15:20:27.488: E/AndroidRuntime(8933): java.lang.NullPointerException
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.example.schoolhelpertesting.AddNewClass.onOptionsItemSelected(AddNewClass.java:44)
05-19 15:20:27.488: E/AndroidRuntime(8933): at android.app.Activity.onMenuItemSelected(Activity.java:2552)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1016)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:496)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:126)
05-19 15:20:27.488: E/AndroidRuntime(8933): at android.view.View$PerformClick.run(View.java:14400)
05-19 15:20:27.488: E/AndroidRuntime(8933): at android.os.Handler.handleCallback(Handler.java:605)
05-19 15:20:27.488: E/AndroidRuntime(8933): at android.os.Handler.dispatchMessage(Handler.java:92)
05-19 15:20:27.488: E/AndroidRuntime(8933): at android.os.Looper.loop(Looper.java:154)
05-19 15:20:27.488: E/AndroidRuntime(8933): at android.app.ActivityThread.main(ActivityThread.java:4945)
05-19 15:20:27.488: E/AndroidRuntime(8933): at java.lang.reflect.Method.invokeNative(Native Method)
05-19 15:20:27.488: E/AndroidRuntime(8933): at java.lang.reflect.Method.invoke(Method.java:511)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-19 15:20:27.488: E/AndroidRuntime(8933): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-19 15:20:27.488: E/AndroidRuntime(8933): at dalvik.system.NativeStart.main(Native Method)
|
Fail to use a substring to print out part of a sentence
The basic algorithm is I have an input file which has number of sentences, each sentence is on each line.I want to print out part of a sentence fro...More
The basic algorithm is I have an input file which has number of sentences, each sentence is on each line.I want to print out part of a sentence from position s to e but with this code below, it prints out blank lines.Can someone show me where my mistakes is?
public class Email13
{
static boolean isValidEmailCharacter(char c)
{
boolean result = false;
if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||(c=='.')||(c=='-')||(c=='+'))
result = true;
return result;
}
public static void main(String[] args) throws Exception{
BufferedReader cin, fin;
cin = new BufferedReader(new InputStreamReader(System.in));
//Description
System.out.println("Programmer: Minh Nguyen");
System.out.println("Description: This program is to start the final project.");
System.out.println();
String nameIn, nameOut, deIn, deOut;
nameIn="";
nameOut="";
deIn = "fileContainingEmails.txt";
System.out.print("Enter input filename [default:" + deIn + "]: ");
nameIn = cin.readLine();
if(nameIn.compareTo("")==0){
nameIn = deIn;
deOut = "copyPasteMyEmails.txt";
System.out.print("Enter output filename [default:" + deOut + "]: ");
nameOut = cin.readLine();
if(nameOut.compareTo("")==0)
nameOut = deOut;
}
else if(nameIn.compareTo("")>0){
deOut = nameIn;
System.out.print("Enter output filename [default:" + deOut + "]: ");
nameOut = cin.readLine();
if(nameOut.compareTo("")==0)
nameOut = nameIn;
}
fin = new BufferedReader(new FileReader(nameIn));
//Read the input file
while(true)
{
if(!fin.ready()) break;
String lineFromFile;
lineFromFile = fin.readLine();
int s, e, hasDot;
for (int i = 0; i < lineFromFile.length(); i++) // for each char in the string...
{
if(lineFromFile.charAt(i)=='@')
{
for(s=i;s>-1;s--)
{
if(isValidEmailCharacter(lineFromFile.charAt(s))==false)
break;
}
for(e=i; e< lineFromFile.length(); e++)
{
if(isValidEmailCharacter(lineFromFile.charAt(e))==false)
break;
}
String anEmail = lineFromFile.substring(s,e);
System.out.println(anEmail);
}
}
}
fin.close();
PrintWriter fout;
fout = new PrintWriter(new FileWriter(nameOut));
fout.close();
}
}
|
How to make my HashTable work on for a specific type
I need to create a HashTable for a project.
Here is how I define what my HashTable is:
public class StudentHashTable<Name...More
I need to create a HashTable for a project.
Here is how I define what my HashTable is:
public class StudentHashTable<Name, DateOfBirth> {
}
The way you would create my HashTable is the following:
StudentHashTable<String,Integer> hashMap = new StudentHashTable<String,Integer>();
As it stands now, it would actually work for any object that has a key of String type and a value of Integer type. What do I need to think about so I can force the HashTable to only accept objects of type Student that has key of String type and value of Integer type?
|
Paths.get()... in other words, If you follow the trail you get lost
In my code I have this instruction:
Path p1 = Paths.get("c:\\java\\");
Being Path just an interface, I was wonderi...More
In my code I have this instruction:
Path p1 = Paths.get("c:\\java\\");
Being Path just an interface, I was wondering what get() was doing inside. So I opened the source code in Path.class and here's what I found:
public static Path get(String first, String... more) {
return FileSystems.getDefault().getPath(first, more);
}
As you can see there is a getPath() that return a Path. So I opened FileSystem.class to see the getPath and here's what I found this time... an abstract method:
public abstract Path getPath(String first, String... more);
How is it possible? This code seems to do nothing and there is also an abstract method so I can't see how it's run. Can someone clarify this?
|
changing the sample Bit Rate of WAV File
I want to changing the Bit Rate of WAV file to speedy up or Slowdown the speech
how Can I do this Pragmatically in C# or Java ??
In my code I have this instruction:
Path p1 = Paths.get("c:\\java\\");
Being Path just an interface, I was wondering what get() was doing inside. So I opened the source code in Path.class and here's what I found:
public static Path get(String first, String... more) {
return FileSystems.getDefault().getPath(first, more);
}
As you can see there is a getPath() that return a Path. So I opened FileSystem.class to see the getPath and here's what I found this time... an abstract method:
public abstract Path getPath(String first, String... more);
How is it possible? This code seems to do nothing and there is also an abstract method so I can't see how it's run. Can someone clarify this?
|
LWJGL - not all display lists rendering
I'm working on a Minecraft like game. I create display list for each 16x16x16 chunk. It works fine. But when I'm trying to add block select...More
I'm working on a Minecraft like game. I create display list for each 16x16x16 chunk. It works fine. But when I'm trying to add block selection it's invisible. It appears only when I'm at some random positions(I render selection at 0, 0, 0) . I have no idea what is wrong.
My render loop:
while (isRunning) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
timer.nextFrame();
input(timer.getDelta());
tex.bind();
glLoadIdentity();
renderChunks();
renderText();
renderSelection();
Display.update();
errorCheck();
if (Display.isCloseRequested()) {
isRunning = false;
}
}
renderChunks:
glRotated(player.getRy(), 1, 0, 0);
glRotated(player.getRx(), 0, 1, 0);
glTranslatef(-player.getX(), -player.getY(), -player.getZ());
//---------
for (int x = minWorldChunkX; x < maxWorldChunkX; ++x) {
for (int y = minWorldChunkY; y < maxWorldChunkY; ++y) {
for (int z = minWorldChunkZ; z < maxWorldChunkZ; ++z) {
glPushMatrix();
glTranslatef(x << 4, y << 4, z << 4);
glCallList(chunkDisplayLists.get(new ChunkPosition(x, y, z)));
glPopMatrix();
}
}
}
renderSelection:
glPushMatrix();
glCallList(selectionDisplayList);
glPopMatrix();
selection display list:
selectionDisplayList = glGenLists(1);
glNewList(selectionDisplayList, GL_COMPILE);
glBegin(GL_LINES);
glColor3f(0, 0, 0);
glLineWidth(3);
glVertex3f(1, 1, 1);
glVertex3f(1, 0, 1);
glVertex3f(1, 0, 1);
glVertex3f(1, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(1, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(0, 1, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
glVertex3f(0, 0, 1);
glVertex3f(0, 1, 1);
glVertex3f(0, 1, 1);
glVertex3f(0, 1, 0);
glVertex3f(0, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(0, 0, 1);
glVertex3f(1, 0, 1);
glVertex3f(0, 1, 1);
glVertex3f(1, 1, 1);
glEnd();
glEndList();
Source code is avaible on my github
EDIT:
When I moved renderSelection() from render loop to renderChunks() before rendering chunks it worked. But when I change renderSelection() to:
glPushMatrix();
glDisable(GL_DEPTH_TEST);
glCallList(selectionDisplayList);
glEnable(GL_DEPTH_TEST);
glPopMatrix();
It disappears completely.
EDIT 2:
Disabling blending while rendering selection fixed it.
screenshos
|
Position and orientation of robot in a grid
I want to make a 10x10 grid and put the robot in position (10,1) (bottom left). I want this robot to be able to move forward, turn left/right and to...More
I want to make a 10x10 grid and put the robot in position (10,1) (bottom left). I want this robot to be able to move forward, turn left/right and to pick up/put objects in a grid. When put in any position, there should be number in a grid which shows how many objects is put in this position, just like this:
..........
...1......
..2.......
....3.....
..........
..........
......9...
.....4....
.........1
..........
We will not see the robot in a grid. I have two classes. Class Robot:
public class Robot {
private Area area;
private Robot rob;
public Robot(Area area){
this.area = area;
rob = new Robot(area);
}
public void Right(){
}
public void Left(){
}
public void Forward(){
}
public void Put(){
}
public void PickUp(){
}
public (?) getPosition(){ // should return robot's position
}
}
Class Area:
private int numberOfObjects;
private Robot robot;
private static final int X = 10;
private static final int Y = 10;
private Object [][] area; // grid
public Area(){ // defines a grid and robot
area = new Area[X][Y];
for(int a=0;a<X;a++){
for(int b=0;b<Y;b++)
area[a][b]=".";
}
numberOfObjects = 0; // grid is initially empty
Area ar = new Area();
robot = new Robot(ar);
}
public void Put(int x,int y){ // put the object to position (x,y)
area[x][y]=numberOfObjects++;
}
public void PickUp(int x,int y){ // pick up the object in position (x,y)
if(area[x][y]!=null){
area[x][y]=numberOfObjects--;
}
}
public void PrintAGrid(){
for(int r=0;r<X;r++){
for(int c=0;c<Y;c++)
System.out.print(area[r][c]+" ");
System.out.println();
}
System.out.println();
}
}
How can I put the robot in position (10,1)? How can I declare and set its orientation (i.e. on the right)? I guess it will be easy to write other methods, so I do not focus on it.
|
How to create a sub array of objects in java?
I have one object array with 100 objects.
I created one sub of the above mentioned array with 10 objects.
Now i want the remaining 90 objects as a n...More
I have one object array with 100 objects.
I created one sub of the above mentioned array with 10 objects.
Now i want the remaining 90 objects as a new array.
What is the java code to do that?
|
Java XML Reading an XML file from top to bottom
I want to read an XML starting from the top to the bottom using Java. However, I don't want to use recursive functions because I want to be able to ...More
I want to read an XML starting from the top to the bottom using Java. However, I don't want to use recursive functions because I want to be able to jump to a different element and start reading from that position.
I've tried using getParent() and indexOf() methods (All three libraries below have these methods) to do this, but it's gotten very messy, mainly because the methods don't distinguish between attributes and elements.
I'm sure there must be a simple way to do this, but after trying dom4j, jdom, and xom, I still have not found a solution.
[Edit] More Information:
My friend wants to make a console text-based game in a question/answer type style. Instead of hard-coding it into java, I decided to try and make it read an XML file instead, because XML has a tree-like style that would be convenient. Here is an example of what my XML file might look like:
<disp>Text to be displayed</disp>
<disp>Text to be displayed afterward</disp>
<disp>What is your favorite color?</disp>
<question>
<answer name="orange">
<disp>Good choice.</disp>
<!-- More questions and stuff -->
</answer>
<default>
<disp>Wrong. The correct answer was orange.</disp>
</default>
</question>
I don't know if it taboo to use XML like an pseudo programming language. If anyone has other suggestions feel free to give them.
|
JAX-RS: Authenticate with multiple principals (more than just username)
Using a Jersey service, what would be the most elegant method to authenticate a user with more than just username and password? say, a Business Id, ...More
Using a Jersey service, what would be the most elegant method to authenticate a user with more than just username and password? say, a Business Id, and username as the Principals, and password as the only Credential.
I have a postgres DB with a users table, the same username string can exist for multiple Business entities. (A unique constraint belongs to two columns, Business id and username together).
I Use Basic authentication, having the client send an additional HTTP Header for the Business id. how do I go on from here?
Now, Regarding Authorization, how would I set up Roles and Permissions, if roles are created specifically for each business entity (each business can define it's own roles and connect it to permissions.)? Permissions are static.
does apache shiro (or any other pluggable security extension) offer a solution in this case?
Thanks.
|
Add html tags to list view row text
In my app i will create listview , the normal construction of string will be as bellow :
final ListView listview = (ListView) fin...More
In my app i will create listview , the normal construction of string will be as bellow :
final ListView listview = (ListView) findViewById(R.id.listview);
String[] values = new String[] { "one", "two", "three",
"four"};
but i want to add html tag to text appear on each row so i have to refer text to string as bellow :
one.setText(Html.fromHtml(getString(R.string.one)));
two.setText(Html.fromHtml(getString(R.string.two)));
three.setText(Html.fromHtml(getString(R.string.three)));
four.setText(Html.fromHtml(getString(R.string.four)));
Which i mean the text appear in list view row can be can be created like :
String[] values = new String[] { "one", "two", "three",
"four"};
Or refered to string-arry as bellow :
<string-array name="days">
<item>one</item>
<item>two</item>
<item>three</item>
<item>four</item>
</string-array>
But this is not what i want , i want to retrive text from string .xml which will be customized by html tag but i dont know what to write in class instead .
UPDATE:
AS answerd bellow i did it this way:
MyArrayAdapter:
public class MyArrayAdapter extends ArrayAdapter<String> {
private final Activity context;
Typeface tf;
static class ViewHolder {
public TextView text;
}
public MyArrayAdapter(Activity context, String string) {
super(context, R.layout.list_item);
this.context = context;}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
tf=Typeface.createFromAsset(context.getAssets(),"BFantezy.ttf");
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.list_item, null);
int resourceToUse = 4;
switch(position){
case 1:
resourceToUse = R.string.day1;
break;
case 2:
resourceToUse = R.string.day2;
break;
case 3:
resourceToUse = R.string.day3;
break;
case 4:
resourceToUse = R.string.day4;
}
ViewHolder viewHolder = new ViewHolder();
viewHolder.text = (TextView) rowView.findViewById(R.id.label);
viewHolder.text.setTypeface(tf);
viewHolder.text.setText(Html.fromHtml(context.getString(resourceToUse)));
rowView.setTag(viewHolder);}
rowView.getTag();
return rowView; }}
AndroidListViewActivity:
public class AndroidListViewActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new MyArrayAdapter(this, resourceToUse));
}
}
i get red line error under resourceToUse in AndroidListViewActivity class .
is there is any way to do it , any help will be appreciated , thanks
|
jquery load array parameter to spring mvc controller
I am trying to pass long array from jquery load to spring controller. I have passed string variable succefully but not the array.
javascript...More
I am trying to pass long array from jquery load to spring controller. I have passed string variable succefully but not the array.
javascript:
function ModuleMemberCheckboxPassIds(){
var memberUserIds = [];
var memberNames = [];
$('.membercheckbox:checked').each(function(i){
memberUserIds[i] = $(this).val();
});
alert(memberUserIds.length);
$( "#onetextarea" ).load('/assign_task', {"memberUserIds":memberUserIds, "testdata": "test", });
}
spring controller:
@RequestMapping(value="/assign_task")
public String viewAssignTask(Model model, String testdata, HttpServletRequest request){
if(request.getAttribute("memberUserIds")==null) System.out.println("null"); else System.out.println("not null"); //returns null
System.out.println("test: " + testdata);//returns a value
model.addAttribute("transferVO", new TransferVO());
return "module/view-members-checkbox";
}
In viewAssignTask method I was able to read tesdata variable that was sent from jquery. But memberUserIds returns null
please help
|
JAR File Fails - Maven & Hibernate Project
I have an app that do simple CRUDs ops (Create, read, update, delete with MySQL).
This app is with maven & hibernate. Everything is fine when I ...More
I have an app that do simple CRUDs ops (Create, read, update, delete with MySQL).
This app is with maven & hibernate. Everything is fine when I debug and execute the app into the IDE (eclipse).
But I need to create a jar of this app, I tried and when I execute the new .jar file looks that everything is ok.
The real problem is when I execute any action for example insert a new record. I fill the textfields and click into the buton to save... but DONT DO NOTHING!
The app only display the GUI but dont do nothing, dont save, dont update dont delete.
What is wrong? exist any special guide to create a .jar file with hibernate?
What should do?
---------------Update-------------
Well I did many thing I created the .jar file with the shell and looks ok I create the manifest and is ok but is the same problem when I launch the .jar from shell show me this:
Could not initialize the database. java.lang.ClassNotFoundException:
com.mysql.jdbc.Driver
Looks like the jar cannot found the classpath to mysqulconnector.jar... but is weird because I declare it in the manifest "Class-Path: connector.jar" I dont know how do it.
What should do "attach" or declare the jar to connect to db?
Thanks in advance.
|
primefaces partial processing not working
I would like to use partial processing but it does not work in my code. Does anybody knows why?
<h:form id="frmVehicle" prependId...More
I would like to use partial processing but it does not work in my code. Does anybody knows why?
<h:form id="frmVehicle" prependId="false">
<p:toolbar styleClass="form_toolbar">
<p:toolbarGroup>
<p:commandButton id="save" process="@(form :not(.noupdate)" value="#{uimsgs.save}" action="#{vmsVehicleActionBean.save()}"
</p:toolbarGroup>
</p:toolbar>
<p:messages id="vmsgs" severity="error,warn" autoUpdate="true" />
<p:tabView id="tabViewSections" orientation="left" styleClass="ses-ui-tabs-left">
<p:tab title="#{vms_uimsgs['vehicle.tab.data']}">
<p:panelGrid id="gridHeader" columns="4" columnClasses="form-label,form-input,form-label,form-input" styleClass="form-grid" >
<p:outputLabel for="kmStatus" value="#{vms_uimsgs['vehicle.kmStatus']}" />
<p:inputText id="kmStatus" value="#{vmsVehicleActionBean.vehicle.kmStatus}"/>
<p:outputLabel for="powerKw" value="#{vms_uimsgs['vehicle.power']}" />
<p:inputText id="powerKw" styleclass="noprocess" value="#{vmsVehicleActionBean.powerKw}">
<p:ajax event="keyup" update="powerPs" />
</p:inputText>
<p:outputLabel value="kw" />
<p:inputText id="powerPs" styleclass="noprocess" value="#{vmsVehicleActionBean.powerPs}">
<p:ajax event="keyup" update="powerKw" />
</p:inputText>
<p:outputLabel value="ps" />
</p:panelGrid>
</p:tab>
</p:tabView>
</h:form>
The two setters (kw & ps ) are still processed. Any idea?
|
Why does WatchService generate so many operations?
import java.io.*;
import java.nio.file.*;
public class Tmp {
public static void main(String [] args) throws IOException {
int ...More
import java.io.*;
import java.nio.file.*;
public class Tmp {
public static void main(String [] args) throws IOException {
int count = 0;
Path path = Paths.get("C:\\tmp\\");
WatchService ws = null;
try {
ws = FileSystems.getDefault().newWatchService();
path.register(ws, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE,
StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.OVERFLOW);
} catch (IOException ioe) {
ioe.printStackTrace();
}
while(true) {
WatchKey key = null;
try {
key = ws.take();
} catch(InterruptedException ie) {
ie.printStackTrace();
}
for(WatchEvent<?> event: key.pollEvents()) {
switch(event.kind().name()) {
case "OVERFLOW":
System.out.println(++count + ": OVERFLOW");
break;
case "ENTRY_MODIFY":
System.out.println(++count + ": File " + event.context() + " is changed!");
break;
case "ENTRY_CREATE":
System.out.println(++count + ": File " + event.context() + " is created!");
break;
case "ENTRY_DELETE":
System.out.println(++count + ": File " + event.context() + " is deleted!");
break;
default:
System.out.println(++count + ": UNKNOWN EVENT!");
}
}
key.reset();
}
}
}
When I run this and then opened the Notepad++ and then created a new empty file and saved it as a.txt in the C:\tmp\ directory I got the output:
1: File a.txt is created!
2: File a.txt is deleted!
3: File a.txt is created!
Why is that? It looks like the file was created and then deleted and then created again. Why?
When I put some text in the file and saved it the output was:
4: File a.txt is changed!
5: File a.txt is changed!
Why did it change twice?
|
JDK was not found on the computer for netbeans 6.5
- I got the following message when open the netbeans. I have got the jdk installed, and set the bin directory in the environment. What I could d...More
- I got the following message when open the netbeans. I have got the jdk installed, and set the bin directory in the environment. What I could do next to avoid this problem? Btw, I am using Windows 7 64 bit.

|
Jmeter - simulating more complex load scenarios?
Been experimenting with Jmeter, and I'd like to know the best way to accomplish:
20 users logging onto an application, over 20 minutes, and...More
Been experimenting with Jmeter, and I'd like to know the best way to accomplish:
20 users logging onto an application, over 20 minutes, and performing some actions for another 20 minutes, before logging off over a period of 20 minutes. I.e. have 200 users logging on, and then once ALL of them are logged on, begin 20 minute timer. Once 20 minutes are up, start to log the ones who logged on earliest off.
I realise this MAY or MAY NOT BE a realistic testing scenario, but i'd like to see if it's possible.
At the moment I have a test plan whereby a user logs on, performs some actions, and then logs off. I can't see how I can ramp up and ramp down.
|
JAX-RS --- How to return JSON and HTTP Status code together?
I'm writing REST web app (Netbean6.9, JAX-RS, Toplink-essential) and trying to return JSON and Http status code.
I have code ready and worki...More
I'm writing REST web app (Netbean6.9, JAX-RS, Toplink-essential) and trying to return JSON and Http status code.
I have code ready and working just to return JSON when HTTP GET Method is called from client.
Code snippet
@Path("get/id")
@GET
@Produces("application/json")
public M_機械 getMachineToUpdate(@PathParam("id") String id) {
//some code to return JSON
.
.
return myJson
But I also want to return HTTP status code (500, 200, 204 etc) along with returning JSON.
I tried using HttpServletResponse object,
response.sendError("error message", 500);
But this made browser to think it's real 500 so output web page was regular Http 500 error page.
What I want to is just to return status code so that my Javascript on client side can handle some logic depending on what HTTP status code is returned. (maybe just to display the error code and message on html page.)
Is it possible to do so? or should HTTP status code not be used for such thing?
|
How can I set the welcome page to a struts action?
I have a struts-based webapp, and I would like the default "welcome" page to be an action. The only solutions I have found to this seem to be variat...More
I have a struts-based webapp, and I would like the default "welcome" page to be an action. The only solutions I have found to this seem to be variations on making the welcome page a JSP that contains a redirect to the action. For example, in web.xml:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
and in index.jsp:
<%
response.sendRedirect("/myproject/MyAction.action");
%>
Surely there's a better way!
|