|
Member 14133670 wrote: Interface will be in swing
Presumably a class assignment.
Just noting that you probably should put more effort into the back end and spend as little time on this swing part as possible. Any use of swing is going to be very limited in the business space.
Member 14133670 wrote: I need help with what classes
I think you should do this yourself. It is like using a hammer for the first time - watching a video of someone using a hammer is not going to help you when you swing the first time. Even though you are going to hit your thumb you just need to do it.
|
|
|
|
|
Hello. Please what can I do to continue coding java ide when after running it says code too large. the codes are well above 1000 and I still need to code more.
|
|
|
|
|
Please provide some more details, your question is not clear.
|
|
|
|
|
The program is to create an excel sheet after some computations and tabulations through a designed interface.The codes is about 6000. when I continue to add more codes for further task, it displayed an error message that, code too large, after running it. Is their any way to make it run after more codes. Alternatively can you show me how to access text field from a different class to minimize the codes. thank you
|
|
|
|
|
I am sorry, but that does not make anything clearer. What do you mean by "The codes is about 6000", and where does the error message occur, and what is the exact text?
|
|
|
|
|
Ok. Can you assist me on how to access textfield from a different class in the same package (i.e to reference a JTextField from a diffrent class). Thank you.
|
|
|
|
|
From what I can understand, you have a class or method that is too long for the generated code to be able to run. You need to break it down into smaller pieces.
Referencing any item from a different class just requires a method that provides access to the item in the class.
|
|
|
|
|
Java does not allow a 'method' to be more than 64k byte codes (internal java compiled representation.)
So you have a method that is too large and you MUST break it into smaller methods. That would be the only possible solution.
In some cases if you are attempting to initialize static data, for example an array, list, etc, as a local variable you will get this error also because initialization is handled by the java compilers by creating a hidden method. Solution for that is to change how the initialization is done such as loading the data from a file.
|
|
|
|
|
Without entering in deep functionality of Servlets, what is it's use? To run some code, and at the end to redirect the user to another web page?
I'm asking because maybe there are some situations where you don't need to redirect the user to another page after the Java code from servlet is done. In this case, is there a way to stop the servlet from redirecting the user to another page? Even if you don't add a redirect or forward to the servlet, it will still redirect the user to it's map url.
|
|
|
|
|
|
Actually I've done that too, that is why I added this in my question, and why I didn't asked only it's purpose:
Quote: is there a way to stop the servlet from redirecting the user to another page? Even if you don't add a redirect or forward to the servlet, it will still redirect the user to it's map url.
|
|
|
|
|
A servlet is merely a program: it does what the code tells it to do. If you have a specific code problem then I would suggest opening a question with the details.
|
|
|
|
|
A HTTP servlet services HTTP requests, and it must finish the processing by sending a valid HTTP response to the client. The response doesn't need to be a redirect.
|
|
|
|
|
I need a human understandable definition of how java script interprets. It seems to be a dance between html pages and forms, and .js Files. I have 40 years experience in coding in 'C' and 'CPP'. The syntax of java is indeed similar. This language provides apparently no type info of any kind. params, indeed the whole of js seems to be devoid of types.
Issues are the relation between the JS Code and the pages using it That is totally unclear. Next, how do I debug Javascript. How do I set breakpoints? what software should use to code in Javascript.
Help Please!
Bram
Bram van Kampen
|
|
|
|
|
|
As Richard has pointed out - you'll get better answers in the right forum.
In the meantime - this article might help with the whole "how does it work" question How does JavaScript work and how can I build simple calculators with it? | HowStuffWorks[^]
There are further links in that article to other interesting "stuff" to help you in your research.
Note that I'm not actually advocating the how stuff works site per se, but you can pick up useful terminology that makes google searches more focussed.
|
|
|
|
|
Hi, I have two files one - client side in Java script, the other in Java - server side ..
I can not send and receive messages What is the problem? Thanks
Js:
<!doctype html>
<html>
<head>
<meta charset = "utf-8">
<title> Wiki Project </title>
<script type = "text/javascript">
window.addEventListener("load", onLoad, false);
function onLoad()
{
var ws_address = "ws://0.0.0.0:8090";
var socket = new WebSocket(ws_address);
socket.onopen = function(event) {onOpen(event);};
socket.onclose = function(event) {onClose(event);};
socket.onmessage = function(event) {onMessage(event);};
}
function onOpen(event)
{
alert("OPEN Connection");
}
function onClose(event)
{
alert("CLOSE Connection");
}
function onMessage(event)
{
alert(event.data.toString());
}
function insertMessage()
{
socket.send(document.directing.message.value);
document.directing.message.value = "";
}
function viewMessages()
{
socket.send("@View@");
}
function deleteMessage()
{
socket.send("@Delete@");
}
</script>
</head>
<body>
<form name = "directing" method = "post" action = "javascript:;">
Write a message:
<input type = "text" name = "message" size = "50" maxlength = "50" />
<input type = "button" name = "add_message" value = "Add to server" onclick = "insertMessage()" />
<input type = "button" name = "view_messages" value = "view messages from server" onclick = "viewMessages()" />
<input type = "button" name = "delete_message" value = "delete message from server" onclick = "deleteMessage()" />
</form>
</body>
</html>
Java:
package com.mycompany.wiki_project;
import io.vertx.core.Vertx;
class VertxServer
{
private static int place;
private static String store_in_server[];
private static String message_from_client;
public static void main(String args[])
{
place = 0;
store_in_server = new String[50];
Vertx vertx = Vertx.vertx();
vertx.createHttpServer()
.websocketHandler(ws -> ws.handler(ws::writeBinaryMessage))
.requestHandler(req ->
{
req.handler(buffer ->
{
message_from_client = buffer.getString(0, buffer.length());
switch (message_from_client)
{
case "@View@":
for (int i=0; i < place; i++)
req.response().write(store_in_server[i]);
break;
case "@Delete@":
place--;
break;
default:
store_in_server[place] = message_from_client + "\n";
place++;
break;
}
});
}).listen(8090);
}
}
|
|
|
|
|
You are trying to send to an invalid address.
|
|
|
|
|
How do I write this?
I need them both to listen to Port 8090
|
|
|
|
|
The port number is fine, but you are using the IP address 0.0.0.0.
|
|
|
|
|
i use
var ws_address = "ws://" + document.location.host + document.location.pathname + ":8089";
not work
|
|
|
|
|
Try connecting to the server code through a browser to see if it will accept a normal request. I do not know Vertx so you may need to use their support lines for help.
|
|
|
|
|
I just started to learn Java Servlet, but I can't really make it work.
I'm trying to do something basic first, to see how it works, read data from a form, print the 2 values to in the console and then redirect the user to another page.
Using the following code (what I though it will do it), redirects me to another page that doesn't exist "/Testare?firstName=Example+First&lastName=Example+Last"
I'm using Apache Tomcat for server.
The form is on Home.html:
<form action="Testare" method="GET">
First name:<br> <input type="text" name="firstName"><br>
Last name:<br> <input type="text" name="lastName"><br>
<br> <input type="submit" value="Submit">
</form>
Testare servlet doGet trying to print and then redirect to "Test.html":
System.out.println("First name: " + request.getParameter("firstName") + "\nLast name: "
+ request.getParameter("lastName"));
response.sendRedirect("Test.html");
|
|
|
|
|
Your question isn't clear.
If the redirect page doesn't exist then it isn't going to work regardless of what you do.
If the initial page doesn't exist (it is not serviced) then it will not work regardless of whether the second page exists or not.
Redirection is handled by the browser not the server.
Here is an example which should have a working redirect.
Login and register form in one page in servlet[^]
|
|
|
|
|
I'm not entirely sure, but I think the problem was from web.xml. Now the problem is gone.
|
|
|
|