• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:45
CEST 20:45
KST 03:45
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO8 Preview5[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Maestros of The Game 2 announcement and schedule !7Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Sea Duckling Open (Global, Bronze-Diamond) Maestros of The Game 2 announcement and schedule ! GSL Code S Season 1 (2026) RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
Quality of life changes in BW that you will like ? BGH Auto Balance -> http://bghmmr.eu/ RepMastered™: replay sharing and analyzer site Tulbo's ASL S21 Ro8 Post-Review Why there arent any 256x256 pro maps?
Tourneys
[ASL21] Ro8 Day 4 Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Daigo vs Menard Best of 10 Path of Exile OutLive 25 (RTS Game)
Dota 2
The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread The Letting Off Steam Thread European Politico-economics QA Mega-thread UK Politics Mega-thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1685 users

The Big Programming Thread - Page 614

Forum Index > General Forum
Post a Reply
Prev 1 612 613 614 615 616 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 15 2015 21:03 GMT
#12261
On April 15 2015 13:41 FFGenerations wrote:
ok well i've given up trying to make it work this way for now. i sort of understand what you've been saying earlier about the autogenerated thing being fucked up. what you wrote totally flew over my head before, but you kept railing on about it until i started to understand. thanks all, you've been brilliant!

will move on to trying to parse it myself instead

Good that you're moving in the right direction .

Just a couple things so you don't get overly dissuaded. There's nothing inherently wrong with using auto-generated code, and in fact a lot of major frameworks will have you relying a bit on them (C# with ADO.NET comes to mind). The important thing is to understand why you're using an auto-generator, and how actually interact with it.

Overriding ToString() methods is also a valid option in many cases, and returning the main identifier for an object like a Name is definitely a good time to do it. Of course, in this circumstance it would be a band-aid solution, because inevitably you'll want other information from you objects, and you'll be right back to the same problem you started with.

Finally, parsing text may seem like a massive undertaking at first, but it's something you will be dealing with eventually if you're a programmer of any kind, so it's definitely something worthwhile to learn. Luckily for you, you're dealing with XML, which is basically designed to be parsed easily.
Average means I'm better than half of you.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-15 22:55:38
April 15 2015 22:33 GMT
#12262
i found a pretty crazy good tutorial



i done the basic one first which also shows it being done with Lists then was wondering why the fuck my nested xml wasnt working and then found the person had just uploaded this one, thank god

so ..... the next thing i'm going to find out is how "deep" into the xml file i need to go to get the data i want i guess, or how far i can simplify it before it fucks up on me. i tend to lean towards it being easy now but i might end up having to look at a plugin that jumps to the parts i want, or something, which would be annoying :D since i have 5 days left lol

the xml file starts off something like this

<ann>
- <anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<related-prev rel="related to" id="13312" />
- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>


so thats like

<ann>
<anime> (use @XmlValue here maybe to grab 'anime id' and 'anime name'? need to check what it does exactly)
<info></info>
<info></info> (how to deal with multiple infos? maybe @XmlValue will straight up work here too to grab 'info src'. or maybe the parser will return a List of infos in this case)
.....
</anime
</ann>
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:49:40
April 16 2015 01:32 GMT
#12263
hi, im a bit stuck on this bit

so from what i can gather Ann (top class) returns as a list of Anime objects

the Anime class should have multiple attributes though: name, id and List of Info objects

FIXED
+ Show Spoiler +

so right now i have it looking like this:

public class Anime {

private String id;
private String name;
private List<Info> infolist;
...
public List<Info> getInfolist() {
return infolist;
}

public void setInfolist(List<Info> infolist) {
this.infolist = infolist;
}
...
public Anime(String id, String name, List<Info> infolist) {
this.infolist = infolist;
this.id = id;
this.name = name;
}


this looks different to the Ann class where i have

public class Ann {

private List<Anime> Ann = new ArrayList<Anime>();

@XmlElement(name="anime")
public List<Anime> getAnn() {
return Ann;
}

public void setAnn(List<Anime> Ann) {
this.Ann = Ann;
}


after unmarshalling the xml file into Ann, i am able to perform

for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

this works.

however i am struggling to be able to access the Info list that should be in the anime class.

i guess the question is, how do i correctly set a list of Info as an attribute of the anime class

Anime class did look similar to Ann to begin with, as below, but i thought maybe that was wrong


public class Anime {

private String id;
private String name;
private List<Info> Anime = new ArrayList<Info>();
...
public Anime(String id, String name) {
this.id = id;
this.name = name;
}



i reverted the code back to how it was in the tutorial (where the topmost class had only 1 attribute so i thought it might look different).

then in my unmarshaller i added a 2nd for loop to try to access the Info list , somehow i got the right syntax


for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

for (Info temp : anime.getAnime()){
System.out.println("Info: "+temp.getSrc());
}
}
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 01:53:34
April 16 2015 01:47 GMT
#12264
+ Show Spoiler [you fixed it] +
private List<Info> Anime = new ArrayList<Info>();

Why is the name of the variable Anime? Do you even need this field? Each Anime having a list of "Info" (whatever that means) seems pretty stupid in the first place. If you need more fields you can create them and call them things that actually make sense. You'd want to add fields for say release date or author rather than creating a list of Info.


I really dislike the idea of this Info class, but if it works then I won't rain on your parade.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:59:28
April 16 2015 01:53 GMT
#12265
i'm using Info because its one of the XML tags... it occurs dozens of times for each anime entry with just random different info in:

- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
etc


so i'm currently saving everything in an info tag into an Info object


@XmlRootElement (name="info")
public class Info {

private String src;

@XmlAttribute(name="src")
public String getSrc() {
return src;
}


and taking the @XmlAttribute from each info entry (if it exists) (only 1 exists per anime and i only need the 1, so that's handy) and accessing it with info.getSrc

right now i'm getting....

[image loading]

which is basically "HOLY FUCK I DONE IT AND SO FAST LOL OMFG TNX TUTORIAL also tnx brain and planning on paper lol"

btw is it normal for netbeans to ramp up to 1,300,000 memory lol

look lol

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 02:05:16
April 16 2015 01:58 GMT
#12266
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


Well each of those Info objects is at least 20 bytes and then you have a ton of them per parse so...

catch (Exception e)


My eyes are bleeding. I guess if you're just going to print the message then maybe it doesn't matter, but ^_^
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 02:36:54
April 16 2015 02:05 GMT
#12267
what i would delete that shit but it probably goes all red

i'm going to use the data to populate a webpage frontend for the user and also save it to a local database or do something else with it

i guess my next task is to go figure out the API get request so it doesn't look like a complete hackjob




i have a sort of interesting question .... how would i describe what this is doing in non-retard terms? for example i am trying to describe it like:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 02:47 GMT
#12268
I'm pretty bad at jargon too, so can't really help you there . It's basically a practice thing.

Also, you seem to over-complicating things by having an Info class. If the data is stored like this:
<anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>
</anime>


Then you should be parsing the type field in the info tags, and then pass the value into a variable in the Anime class. Basically, your class should look something like this:
class Anime{
private string title;
private string altTitle;
private string genre;
private List<string> themes; //assuming >1 theme is possible, otherwise just a single string
private double runTime;
}
Average means I'm better than half of you.
phar
Profile Joined August 2011
United States1080 Posts
April 16 2015 03:05 GMT
#12269
^^ strongly agree with using separate fields for things instead of just generic repeated info

You can heave a repeated info for unknown info tags if you want, but try to get more stuff parsed in up front, it's more useful.
Who after all is today speaking about the destruction of the Armenians?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 03:07:43
April 16 2015 03:06 GMT
#12270
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 03:21:46
April 16 2015 03:19 GMT
#12271
i'm not sure if that is possible

the way i am doing it is

look at @XmlRootElement (name="info")
look at @XmlAttribute(name="src")
save this


if there is an xml parser functionality that lets me check for Picture inside Infos then take the corresponding SRC from that Info and put it straight into Anime then sure....but i don't know if @XmlAttribute or @Something exists to do that

if anything there might be a plugin that lets you do that, like it autoscans the document and returns X for your nomatter where X is located...........

there is no fucking way i'm getting into that though :D i've got 4 days to finish this and then 4 days to do 2 other major assignments . edit: unless there is @functionality that just does that.............
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
April 16 2015 03:23 GMT
#12272
On April 16 2015 12:06 Blitzkrieg0 wrote:
Show nested quote +
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.


i was just describing the "prototype version" for when i have to write about it and sound mildly technical or whatever
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 03:29 GMT
#12273
Well, can't help you with the specifics because I haven't used JAXB before. That said, this is the part where you learn that your power to Google is what makes you a programmer :D.
Average means I'm better than half of you.
ArchmageKruzer
Profile Joined August 2013
64 Posts
April 16 2015 03:43 GMT
#12274
So a couple of my friends and I want to make an IOS game. Currently we're writing the code in Java and then we're gonna import it into IOS. My question is is this a good idea, and if so, do you have any tricks and stuff to make the import easier, since there are probably gonna be like a million things going wrong once we do it.
Also, i've been poking around for engines, and 5 mins of google got me to the Unreal engine, which seems pretty OK. Any engine suggestions for IOS games, and tips/tutorials on how to use them?
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 13:17:07
April 16 2015 04:30 GMT
#12275
+ Show Spoiler +
(ignore this bit)
+ Show Spoiler +
so apparently you don't need to use REST web services, you can just have

URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~neon genesis" );

Ann ann = (Ann) ums.unmarshal(url);

and it does the get request and puts it straight into your parser. wtf. that is insane
i just shaved like 40 years off my life


i think i move on to figuring out how to make it into MVC now with a basic web frontend and then add a database functionality and then add jquery stuff



question about what i do next:

am i supposed to have the anime classes as managed java beans or can i keep them as they are and just print the data to a jsp page via a servlet controller?

ive been fucking around for a while and ended up with an insane mess and getting no error but it just fails to run with no error specification . at one point i tried to add bean annotations ontop of the xml annotations but it gave me a frowny face and i backed off for the time being

this is what i've got in my head so far:
1) jsp frontend page that takes the user's search string in a form
2) servlet page that takes this and passes it to my service class
3) the service class does GET request and parses the response into the anime objects
4) but then how do i access this data ? does it need to be turned into a java managed bean? can i access it directly from the jsp page? does it need to go through the servlet controller?

ill come back in 8 hours or whatever after i slept

have been trying random stuff but there's tons of stuff to try and that's before i even go to one of the super heavy tutorials .

edit: maybe i make session facade bean from the Ann java class and then use that to do stuff. if it lets me annotate it



OK here is what i've got so far. it runs , time-outs for about 9 seconds, then displays the HTML ("end") ie it doesnt display the object data

ControllerServlet.java
+ Show Spoiler +


ControllerServlet.java

package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

@EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB.Unmarshalling("evangelion");

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}


AnnJAXB.java
+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public static void Unmarshalling(String searchString) {
try {

JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );

Ann ann = (Ann) ums.unmarshal(url);


} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}



when i remove the line AnnJAXB.Unmarshalling("evangelion"); it runs and displays the html instantly, so that bit there is causing it to time out and return nothing from it.

the obvious problem is in AnnJAXB at the line

Ann ann = (Ann) ums.unmarshal(url);

for this it says Variable ann is not used

the other bit that looks weird is
 @EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();
bit


posted to stackoverflow, easier to read http://stackoverflow.com/questions/29674404/mvc-object-method-and-serlvet-structure-help-in-java-please


i tried changing AnnJAXB Unmarshall to return an Ann instead of being static void method. i managed to get it to work eventually but its still hanging like previous version then not displaying the object data.

controllerservlet
+ Show Spoiler +


package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
*
* @author J
*/
@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

// @EJB
// private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann;

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB an = new AnnJAXB();
try{
an.Unmarshalling("evangelion");
}catch(Exception e){}

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}



annjaxb

+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public Ann Unmarshalling(String searchString) throws JAXBException, MalformedURLException {


JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );


Ann ann = (Ann) ums.unmarshal(url);

return ann;
}
}



i have no words

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
April 16 2015 19:25 GMT
#12276
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


*reads the word "netbeans"*

*averts his eyes*
Time is precious. Waste it wisely.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 22:38:54
April 16 2015 22:38 GMT
#12277
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-04-16 23:06:49
April 16 2015 23:06 GMT
#12278
On April 17 2015 07:38 FFGenerations wrote:
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min


Are those your only 3 classes in SO. It's kind of hard to troubleshoot code without being able to run it. Did someone already talk to you about possibly putting your stuff on github or something if you want more help?

Edit: Definitely not your only 3 classes. See question above
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:16:17
April 16 2015 23:15 GMT
#12279
hey dude, here is a zip file with the project (if google drive lets you share zipped code)

https://drive.google.com/file/d/0BzIvzoW04fGQbUdMT3RYVXN5ODA/view?usp=sharing


i got stuck trying to get git to work a while back and havent tried to use it since. i will sort that out sometime
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:34:05
April 16 2015 23:26 GMT
#12280
STOP I FIXED IT HOLY FUCKING CHRIST


I changed the loop to say:
+ Show Spoiler +

 for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {


and removed

 annj.Unmarshalling("evangelion");


so it looks like


try{
for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {

out.println("<h1>Loop1</h1>");

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}}catch(Exception e){}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");


pic

+ Show Spoiler +

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Prev 1 612 613 614 615 616 1032 Next
Please log in or register to reply.
Live Events Refresh
uThermal 2v2 Circuit
15:00
Last Chance Qualifier
RotterdaM664
uThermal574
SteadfastSC165
Liquipedia
SC Evo League
13:00
StarCraft Evolution League #22
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 664
uThermal 574
mouzHeroMarine 170
SteadfastSC 165
BRAT_OK 49
MindelVK 29
Vindicta 21
StarCraft: Brood War
Calm 4796
Mini 566
ggaemo 314
firebathero 234
Dewaltoss 132
Backho 45
Hyun 33
Aegong 30
Rock 30
Dota 2
monkeys_forever406
LuMiX1
League of Legends
Reynor10
Counter-Strike
fl0m2488
Fnx 1853
Heroes of the Storm
Khaldor258
Liquid`Hasu224
Other Games
Grubby3431
FrodaN2120
B2W.Neo751
Beastyqt530
Hui .210
Organizations
Other Games
gamesdonequick2903
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 21 non-featured ]
StarCraft 2
• printf 35
• davetesta19
• Adnapsc2 10
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• blackmanpl 24
• FirePhoenix1
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV701
League of Legends
• Jankos1946
• imaqtpie1869
• TFBlade961
Other Games
• Shiphtur274
• tFFMrPink 13
Upcoming Events
BSL
15m
Artosis vs TerrOr
spx vs StRyKeR
Replay Cast
5h 15m
Sparkling Tuna Cup
15h 15m
RSL Revival
15h 15m
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
17h 15m
ByuN vs Rogue
Solar vs Ryung
Zoun vs Percival
Cure vs SHIN
BSL
1d
Dewalt vs DragOn
Aether vs Jimin
GSL
1d 13h
Afreeca Starleague
1d 15h
Soma vs Leta
Wardi Open
1d 17h
Monday Night Weeklies
1d 21h
[ Show More ]
OSC
2 days
CranKy Ducklings
2 days
Afreeca Starleague
2 days
Light vs Flash
Replay Cast
3 days
Replay Cast
4 days
The PondCast
4 days
Replay Cast
5 days
RSL Revival
5 days
Korean StarCraft League
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Escore Tournament S2: W6
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
KK 2v2 League Season 1
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2

Upcoming

BSL 22 Non-Korean Championship
YSL S3
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
BLAST Bounty Summer 2026: Closed Qualifier
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.